I am working with a string variable called "YearofBirth" that includes includes 443 observations of participant birth year. 423 observations have ONLY birth year, but 20 observations have birth day, month and year. I'm wondering if there is a way to generate a new numeric variable for complete birth date (day, month, year) that gives a "generic" day/month (01jan) for the 423 observations that only have the birth year and are missing their actual birth day/month. I am using STATA version 16.
Please let me know if I need to be more clear. I'm relatively new to Stata so I may have some terminology wrong. Thanks so much for your help!
Here is what my data looks like:
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input str12 YearofBirth "1988" "31dec1988" "1987" "1997" "1998" "1989" "1987" "1985" "1992" "1985" "23jul1998" "23jul1998" "1982" "06oct1999" "1987" "16nov1999" "1991" "1999" "29jan2001" "1985" "04apr1996" "10apr1997" "05oct1995" "1993" "30nov1998" "2001" "01jul1983" "02feb1982" "01oct1985" "01oct1986" "1998" "1982" "1999" "1996" "1994" "17apr1984" "05jun1981" "1996" "1998" "1993" "1992" "10feb1999" "1983" "1988" "1986" "1987" "1988" "1987" "1991" "1982" "1998" "1981" "1995" "1980" "1994" "1982" "1994" "1989" "25feb1979" "1996" "1998" "1979" "1991" "1989" "1982" "1994" "1995" "1980" "1994" "1997" "1984" "2000" "1990" "1986" "2000" "1981" "1998" "1996" "1997" "1992" "1992" "2000" "1986" "1992" "1985" "1986" "1995" "1994" "1993" "1998" "1993" "1990" "1989" "1998" "1992" "1985" "1987" "1981" "1982" "1991" end
0 Response to How to replace missing day/month with a "generic" date (i.e. 01jan) for a string date variable
Post a Comment