![reshape stata reshape stata](https://i.stack.imgur.com/3SkW9.png)
| airline inprog1 i_cnt1 inprog2 i_cnt2 inprog3 i_cnt3 inprog4 i_cnt4 |
![reshape stata reshape stata](https://www.stata-uk.com/media/wysiwyg/software/stata/data-editor-paste-special.png)
> reshape wide i_cnt inprog, i(airline) j(time) By default it exports the data to a layout that is very inconvenient for analysis. The World Development Indicators is a commonly used dataset for macro level data. Reshape World Development Indicators for Stata Analysis. To convert a dataset from long form to wide, simply use -reshape wide- command instead.Ĭonsider the airacc data, to make a simple example, we only keep 3 variables – Home Online Help Statistical Packages Stata Reshape World Development Indicators for Stata Analysis. reshape long name inc, i (famid) j (dadmom) string Let’s look at the data before and after reshaping. In the example below, the string option has been added at the end of the command. Reshape from long to wide: -reshape wide- Stata can handle that as long as you use the string option to indicate that the suffix is a character. > reshape long bp_, i(patient) j(when) string * reshape data, note the string option added at the end * load data and list the first 4 observations Consider another sample data called reshape2. Sometimes a variable called id does not serve as unique identifier – and that’s one of the reasons we need to be careful when reshaping data. Reshape from wide to long: complex unique identifier * we simply put inc and ue as stubs, then put id and year as i and j as we did in the previous example. In this case, 1) the stub should be inc, which is the variable to be converted from wide to long, 2) i is the id variable, which is the unique identifier of observations in wide form, and 3) j is the year variable that I am going to create – it tells Stata that suffix of inc (i.e., 80, 81, 82) should be put in the variable called year. The syntax should look like this in general: reshape long stub, i(i) j(j) * let's make the first example simpler by keeping id, sex and the inc variables Use the reshape (long) command to create a new variable named year.
#Reshape stata code#
| id sex inc80 inc81 inc82 ue80 ue81 ue82 | Stata & R code for course on the fundamentals of data analysis and visualization.
#Reshape stata series#
Program for applying the series descriptors to the variables as variable labels. To keep track of which variable holds the data for which series, we will turn vardesc.do into a We are going to turn each different value of varnum (each WDI series) Labels to values of the "varnum" variable. The "label save" command creates vardesc.do, a do file for applying the WDI series descriptors as Read the file into Stata using the "insheet" command. Save the file as as comma separated values (.csv). WDI data as downloaded from the World Bank web site:įirst, open the spreadsheet in Excel and add a "y" in front of the year column headers, so they For a more comprenhensive set of instructions on reshaping (long to wide Below are a series of steps to convert it into a "long" form, appropriate for analysis as panel data. From the WDI page you can export the data to a usable datataset without the need to reshape it, click hereįor instructions (make sure 'Country' is in row and 'Series' in columns, remove 'Time' from column and put it in the page
![reshape stata reshape stata](https://www.ssc.wisc.edu/sscc/pubs/screenshots/sfr/ui2.png)
The World Development Indicators is a commonly Reshape World Development Indicators for Stata Analysis Reshape World Development Indicators for Stata Analysis Home Online Help Statistical Packages Stata Is open as long as Firestone is open, no appointments necessary to use the lab computers for your own analysis.