Hello Statalisters,
I have the following data which gives the ID of the mother (newid), birth order of the child (bord) and year of birth of said child (yobch). I declared the data as an unbalanced panel by
. Data example below. I want to create a dummy variable = 1 (name polexposure) if mother had 2 or more children in 1975, 1976 or 1977 and 0 if the mother had all her children before 1975, or started pregnancy by 1977 or had only one child throughout the 1975-77 period. To be more detailed, in the data below mother with newid 10 has had 6 children, all born before 1975 so I want the value of polexposure value for this id to be zero but the value of polexposure for newid 13 == 1 since she had more than 2 kids before 1975 and her next child was born after 1975. Again, the variable would also be zero for women who had their first child after 1977, or had less than 2 kids in 1975-77.
Do I need to convert this to a woman-year panel or could I work with the data below. If the latter, how do I create this dummy?
The code I have so far is
But this makes woman with newid 13 have some entries equal to zero and will be equal to 1 for newid 10 since she did have more than 3 kids before 1975.
I have the following data which gives the ID of the mother (newid), birth order of the child (bord) and year of birth of said child (yobch). I declared the data as an unbalanced panel by
Code:
xtset newid bord
Do I need to convert this to a woman-year panel or could I work with the data below. If the latter, how do I create this dummy?
The code I have so far is
Code:
gen polexposure = 0 replace polexposure = 1 if bord >=2 & yobch <= 1977
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input float newid byte bord int yobchild 1 1 1985 1 2 1988 2 1 1977 2 2 1985 2 3 1989 2 4 1992 3 1 1967 3 2 1973 3 3 1977 4 1 1989 5 1 1982 5 2 1986 5 3 1991 6 1 1958 6 2 1962 6 3 1964 7 1 1980 7 2 1982 7 3 1984 7 4 1985 7 5 1988 8 1 1985 8 2 1986 8 3 1991 9 1 1984 9 2 1986 9 3 1989 9 4 1991 10 1 1961 10 2 1964 10 3 1965 10 4 1967 10 5 1970 10 6 1971 11 1 1991 12 1 1982 12 2 1985 12 3 1986 13 1 1961 13 2 1964 13 3 1967 13 4 1969 13 5 1971 13 6 1976 14 1 1988 14 2 1991 15 1 1983 16 1 1991 17 1 1986 17 2 1989 17 3 1992 18 1 1979 18 2 1982 18 3 1987 19 1 1965 20 1 1978 21 1 1979 21 2 1983 21 3 1986 22 1 1959 22 2 1960 22 3 1961 22 4 1962 22 5 1963 22 6 1964 22 7 1965 23 1 1984 23 2 1988 24 1 1981 24 2 1984 24 3 1988 25 1 1988 26 1 1983 26 2 1986 26 3 1989 27 1 1960 27 2 1962 27 3 1968 27 4 1971 27 5 1980 27 6 1982 28 1 1956 28 2 1959 28 3 1963 28 4 1966 28 5 1973 28 6 1978 29 1 1983 29 2 1984 29 3 1987 30 1 1981 30 2 1982 30 3 1985 30 4 1987 31 1 1967 31 2 1969 31 3 1970 31 4 1973 31 5 1974 32 1 1987 end
Comment