I have several spreadsheets that contain panel data in a "wide" format
on a single variable: dates across the top, cross-sectional identifiers
down the left. I have been reading them into Stata with -insheet- (as
CSV) and then using -reshape-, but find that this approach is
sub-optimal in that I often loose the dates -- they are recast as v2,
v3, etc. I can write code to re-create the dates, but this practice
is neither transparent nor general. (Transposing the data hasn't
helped: then I loose the cross-section identifiers.)
I'm curious how other people approach this issue. Perhaps there is a
better way to organize the data in the spreadsheet, or perhaps I should
use a different Stata command. I've looked briefly at -infix- and
- -infile-, but they don't seem to address this particular issue. (The
data are balanced and comma-separated.) But then again, I may be
missing something.
My ultimate goal (conceit?) is something sufficiently transparent (a
few lines of code?) that I can give to undergrads with limited Stata
experience and have them pull off a data import of this type without
any problems -- or intervention by me. This seems like it should be
much simplier than I have made it so far. Thanks in advance for any
suggestions.
I have some code that does the inverse of what you want, which might
nevertheless be useful in setting something up for your problem. We
have a web-based database access system that kicks out panel data on
several variables, for several countries, and whatever years are
specified in long-long format, and of course people do not know what to
do with that. They would like it wide, either to use in Stata or to
(gasp!) put it into a spreadsheet. We indicate that the following
do-file will take the file that they have downloaded and widen it,
labelling things appropriately and getting the time dimension properly
labelled.