You
can find many databases in this form:
Unfortunately,
Stata can't read this form and we must convert this table in a
readable format.
To do this,
just copy the data to the Stata editor:
Then (in Tools
– Variable Properties) change the countries variable name. In my
case I've chosen “country”. You can also do it writing in the
command line: "rename var1 country" (without quotes).
After that, in
the command line, type the following: reshape long var, i(country)
j(year)
"reshape" is the instruction, "var"
is the variable that we want converting, "long" is the
database format, "i" identifies the countries and "j"
identifies the time period.
Now,
our database looks like:
Note that
"country" is a textual variable and we must convert it in a
numerical variable. To do that we can employ the command: encode
country, gen(ncountry)
Finally, to
start working with our panel data, type: xtset ncountry year
This command
specifies who are the subjects (ncountry) and what variable
identifies the time (year)
Good luck!
(Note that the
content of year variable is “2,3,4,5,6” and not “1995, 1996,
1997 etc.
I've changed
the content manually but I'm sure there is a way to do automatically,
with the "replace" command or some other. If you have the
solution, please let me know :)