Dear Statalist,
I’m having problems with looping through variables. I am using Stata 15.1 for Windows.
I have a large dataset (please, see below) containing multiple measurement points of each individual. I want to generate a variable indicating individual's age at the year she gave birth to her first child (age_at_birth). For the first individual, this age would be 16 since the birth_year is 1999 and she was 16 years at 1999, for the second individual this age would be 16 since the birth_year is 1998 and she was 16 years at 1998, and so on. I understood the Stata command -forvalues- should be used but I did not manage to write a working code.
Moreover, I have a variable measuring occupation (nominal variable, gets values between 1 and 4) and I would like to generate a variable measuring individual's occupation one year before she gave birth to her first child (variable occup_1yr~h) and three years after she gave birth to her first child (occup_3yr_~h). Again, I think -forvalues- should be used for this kind of modifications and I am grateful for any tips on how to get started.
Array
Thank you very much for your help,
Julie
Related Posts with Confusion with looping
AR 1 Auto correlation errorI am using a mixed model regression to determine what influences my response variable (V1), includin…
suest with multiple imputationsHi all: This is my first post. I'm an old time SAS user converting to stata. I want to compare coeff…
Merging multiple files in a loopHi, I am trying to merge 12 files with similar files name. Each file just has one variable. I was f…
PPMLHDFE is now on SSC (Poisson regressions with fixed effects)Dear all, Thanks to Kit Baum, the ppmlhdfe package is now on SSC (together with updated versions of…
OLS GravityI'm trying to estimate an OLS gravity equation and I have encountered a problem regarding the model.…
Subscribe to:
Post Comments (Atom)
0 Response to Confusion with looping
Post a Comment