<>
I would rather -reshape- the thing...
***
clear*
//construct data
//20 cases
set obs 20
forv i = 1979/2004{
gen education`i'=/*
*/int(runiform()*10)
}
gen dob_year=int(runiform()*20)+1950
gen id =_n
//reshape for convenience
reshape long education,/*
*/ i( id ) j( year )
l, sepby(id)
***
HTH
Martin
_______________________
----- Original Message -----
From: "Matthew Aronson" <[email protected]>
To: <[email protected]>
Sent: Tuesday, June 16, 2009 11:02 PM
Subject: st: years and ages in variables
My dataset, in the wide form, contains for each respondent a series of
variables that have the form: education1979,
education1980...education2004, where each variable educationYYYY
contains the respondent's educational status during the indicated
calendar year.
I know each respondent's birth year (as a distinct variable,
"dob_year"), and would like to get a series of variables of the form
"education14," education15"...education52.
My idea is that "education14" would hold the respondent's education at
age 14, up to the oldest respondent age of 52. Could someone please
suggest some code to help me figure out this problem?
Matt Aronson
Fort Collins, Colorado USA
*
* For searches and help try:
* http://www.stata.com/help.cgi?search
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/
*
* For searches and help try:
* http://www.stata.com/help.cgi?search
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/