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
Factor variable and interaction in syntax commandHi, I am trying to add interaction terms into a simple new command. Something simple like this: C…
Wald exogeneity test with -biprobit-Dear Statalisters Is there an in-built command/option with -biprobit- which shows the result for Wal…
Meta forestplot and Meta summarizeDear Stata Users, I am working in a meta analysis of prior 20 studies. In several studies I have co…
spmatrix -same coordinatesDear all, I tried to create an inverse spatial weight matrix, but without success. I rely on a cros…
Export first stage results using esttab with ivprobit and birprobitIs there a way to export first-stage results from -ivprobit- and -biprobit- using -esttab-? I know o…
Subscribe to:
Post Comments (Atom)
0 Response to Confusion with looping
Post a Comment