PDA

View Full Version : stata problem



ChicagoChicagoChicago
08-23-2007, 07:50 PM
Hi, I know this might not be the right place to ask, but just in case someone knows how to do this in stata.

I have a big dataset in the following format.

year countryn gdpcap gdpusd gdpgr gdpcapgr
1965 Angola
1975 Angola
1985 Angola
1995 Angola 196.5728 2413.914
2005 Angola 1956, 114 31182.42 11.91778 8.951091
1965 Albania
1975 Albania
1985 Albania
1995 Albania 778.2894 2438.381
2005 Albania 2535.538 7936.233 2.254714 2.257834
and i have 170+ countries with 5 observations, 4 other variables gdpcap, gdpusd, gdpgr, gdpcapgr

I need to change it to the following format
countryn gdpcap1965 gdpcap1975 gdpcap1985, ........gdpusd1965, gdpusd1975, .....................................gdpcapgr2005
Angolia
Albania

so each country will only have one observation, but more variables.

everything need to be done within stata. anyone has some idea?
Thanks

Antichron
08-23-2007, 08:04 PM
You'll want to use the reshape command. It'll be something like

reshape gdpcap gdpusd gdpgr gdpcapgr, i(countryn) j(year)

Check the help file for the exact syntax, though.

Antichron
08-23-2007, 08:06 PM
Sorry:

reshape wide gdpcap gdpusd gdpgr gdpcapgr, i(countryn) j(year)

notacolour
08-24-2007, 01:09 AM
Yep, Antichron is right on. Reshape wide. Read the help for reshape--it has pretty good examples. I have to look it up just about every time I use it, since it seems to be something I need to do every few months or so--just a long enough interval to forget the syntax.

ChicagoChicagoChicago
08-24-2007, 02:58 AM
hi Antichron, thanks a lot!