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

st: Re: years and ages in variables

From   "Martin Weiss" <>
To   <>
Subject   st: Re: years and ages in variables
Date   Tue, 16 Jun 2009 23:32:17 +0200


I would rather -reshape- the thing...


//construct data
//20 cases
set obs 20

forv i = 1979/2004{
gen education`i'=/*

gen dob_year=int(runiform()*20)+1950
gen id =_n

//reshape for convenience
reshape long education,/*
*/ i( id ) j( year )

l, sepby(id)

Martin _______________________ ----- Original Message ----- From: "Matthew Aronson" <>
To: <>
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:

*   For searches and help try:

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