This data set contains data about three countries over three years. The level two unit is thus a country, and the level one unit is a country-year combination. The level two variables are country and area, while the level one variables are year, pop and cgdp. country is the level two identifier and year the level one identifier. Note that countries do occasionally change in area. If your panel included such an event (say, the United States in 1803) then you'd have to treat area as a level one variable throughout.

To reshape this data to wide form the command is:

reshape wide pop cgdp, i(country) j(year)

To go back to long:

reshape long pop cgdp, i(country) j(year)

To collapse to a data set of countries with variables meanPop and maxCGDP:

collapse meanPop=pop (max) maxCGDP=cgdp, by(country)

Note that area disappeared. If you wanted to keep area (which you could, since it's a country-level variable) you'd need to add it to the command, probably using the (first) statistic.

Last Revised: 12/17/2015