Hello
Im trying to categorise a variable for the time for how long a woman has been part of a cohort until she gave birth.
I calculated the difference between the date of registration and date of birth of the baby, and divided by 365,25.
Then I would like to categorise the variable according to years of registration until she gave birth.
Here there is the command:
gen dnascregd_dif = (dnasccri-regdia)/365.25 if (dnasccri!=. | regdia!=.)
replace dnascregd_dif = 1 if (dnasccri-regdia)/365.25 == 1 | (dnasccri-regdia)/365.25 == 2 | (dnasccri-regdia)/365.25 == 3
replace dnascregd_dif = 2 if (dnasccri-regdia)/365.25 == 4 | (dnasccri-regdia)/365.25 == 5 | (dnasccri-regdia)/365.25 == 6
replace dnascregd_dif = 3 if (dnasccri-regdia)/365.25 == 7 | (dnasccri-regdia)/365.25 == 8 | (dnasccri-regdia)/365.25 == 9
replace dnascregd_dif = 4 if (dnasccri-regdia)/365.25 > 9
label define dnascregd_lbl 1 "1-3 years" 2 "4-6 years" 3 "7-9 years" 4 "> 9 years"
label values dnascregd_dif dnascregd_lbl
tab dnascregd_dif, m
When I try to tabulate the results, the STATA output says that there are too many values.
Does someone knows how to correct this?
Thank you
Im trying to categorise a variable for the time for how long a woman has been part of a cohort until she gave birth.
I calculated the difference between the date of registration and date of birth of the baby, and divided by 365,25.
Then I would like to categorise the variable according to years of registration until she gave birth.
Here there is the command:
gen dnascregd_dif = (dnasccri-regdia)/365.25 if (dnasccri!=. | regdia!=.)
replace dnascregd_dif = 1 if (dnasccri-regdia)/365.25 == 1 | (dnasccri-regdia)/365.25 == 2 | (dnasccri-regdia)/365.25 == 3
replace dnascregd_dif = 2 if (dnasccri-regdia)/365.25 == 4 | (dnasccri-regdia)/365.25 == 5 | (dnasccri-regdia)/365.25 == 6
replace dnascregd_dif = 3 if (dnasccri-regdia)/365.25 == 7 | (dnasccri-regdia)/365.25 == 8 | (dnasccri-regdia)/365.25 == 9
replace dnascregd_dif = 4 if (dnasccri-regdia)/365.25 > 9
label define dnascregd_lbl 1 "1-3 years" 2 "4-6 years" 3 "7-9 years" 4 "> 9 years"
label values dnascregd_dif dnascregd_lbl
tab dnascregd_dif, m
When I try to tabulate the results, the STATA output says that there are too many values.
Does someone knows how to correct this?
Thank you

Comment