Hi Everyone,
I am analysing the data collected from NFHS-5 of India for a project.
In the dataset, for each woman respondent, there are data entries (variables) for up to 20 children born to a given woman.
The date of birth of children is coded in two different variables birthmonth1, birthmonth2, birthmonth3 and so on……. Up to 20.
Similarly, the year of birth of the children is given as birthyear1, birthyear2, birthyear3 and so on…………….
I want to generate the date of birth of all the children born to a woman.
Right now I am using the following command
gen dob1= mdy (birthmonth1, 15, birthyear1)
However, I have to repeat the same command 20 times to generate the date of birth for all 20 children.
Is there a way I can loop this may be by using ‘for each’ or any other command?
I don’t want to repeat the command over and over again.
Many Thanks
I am analysing the data collected from NFHS-5 of India for a project.
In the dataset, for each woman respondent, there are data entries (variables) for up to 20 children born to a given woman.
The date of birth of children is coded in two different variables birthmonth1, birthmonth2, birthmonth3 and so on……. Up to 20.
Similarly, the year of birth of the children is given as birthyear1, birthyear2, birthyear3 and so on…………….
I want to generate the date of birth of all the children born to a woman.
Right now I am using the following command
gen dob1= mdy (birthmonth1, 15, birthyear1)
However, I have to repeat the same command 20 times to generate the date of birth for all 20 children.
Is there a way I can loop this may be by using ‘for each’ or any other command?
I don’t want to repeat the command over and over again.
Many Thanks
Comment