I have data that resembles the following:
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input float id str2 varlist float(yr1995 yr1996 yr1997) 1 "x1" 2 23 1 1 "x2" 3 4 3 1 "x3" 2 2 2 2 "x1" 3 2 2 2 "x2" 2 2 2 2 "x2" 1 2 3 end
In the above, I have information by individual id, for different years, for the variables x1, x2 and x3. I wish to reshape this data to long format, where each variable (x1, x2 and x3) is stacked in an independent column, where each entry in the column is the value of that variable for a particular year.
Normally, the reshape command would do the trick, but the fact that there are multiple variables complicates this. Is there a straightforward way to implement this?
Many thanks,
CS
0 Response to Reshaping multiple variables at once
Post a Comment