Statalist


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

st: Re: years and ages in variables


From   "Martin Weiss" <martin.weiss1@gmx.de>
To   <statalist@hsphsun2.harvard.edu>
Subject   st: Re: years and ages in variables
Date   Tue, 16 Jun 2009 23:32:17 +0200

<>

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" <maronson@rams.colostate.edu>
To: <statalist@hsphsun2.harvard.edu>
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/



© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index