I have a data where the age of the child is 1 but I want to replace all the household with children aged 1 to zero which fulfills the following condition
If the age difference between age of the person(age) and the age at first birth(D1) is 1 and there is a new born in the household whose age is 1(age is 1) then I want to replace all the age of the child with age 1 to be zero.
An example of my data
Can you please suggest how can I do that in STATA
thank you
If the age difference between age of the person(age) and the age at first birth(D1) is 1 and there is a new born in the household whose age is 1(age is 1) then I want to replace all the age of the child with age 1 to be zero.
An example of my data
HID | PPID | Rela | sex | age | D1 | D2 |
1 | 1 | Head | 2. Female | 26 | 1. Yes | 25 |
1 | 2 | Daughter | 2. Female | 1 | ||
2 | 1 | Head | 2. Female | 30 | 1. Yes | 29 |
2 | 2 | Daughter | 2. Female | 1 | ||
3 | 1 | Head | 2. Female | 31 | 1. Yes | 30 |
3 | 2 | Daughter | 2. Female | 1 | ||
4 | 1 | Head | 2. Female | 17 | 1. Yes | 15 |
4 | 2 | Daughter | 2. Female | 1 | ||
thank you
Comment