Looking for help converting this STATA to SAS. gen stillbirths = 0
label variable stillbirths "Stillbirths"
gen births = 0
label variable births "Births in calendar"
gen births2 = 0
label variable births2 "Births in birth history"
gen earlyneo = 0
label variable earlyneo "Early neonatal deaths"
gen infant_deaths=0
label variable infant_deaths "infant deaths"
gen child_deaths=0
label variable child_deaths "child deaths"
gen beg = v018
gen end = v018+59
local vcal_len = strlen(vcal_1[1])
quietly forvalues i = 1/`vcal_len' {
replace births = births+1 if inrange(`i',beg,end) & substr(vcal_1,`i',1) == "B"
replace stillbirths = stillbirths+1 if inrange(`i',beg,end) & substr(vcal_1,`i',7) == "TPPPPPP"
}
replace end = v008
replace beg = v008-59
rename b3_0* b3_*
rename b6_0* b6_*
quietly forvalues i = 1/20 {
replace births2 = births2+1 if inrange(b3_`i',beg,end)
replace earlyneo = earlyneo+1 if inrange(b3_`i',beg,end) & inrange(b6_`i',100,106)
replace infant_deaths = infant_deaths+ 1 if inrange(b3_`i',beg,end) & inrange(b6_`i',100,211)
replace child_deaths = child_deaths+ 1 if inrange(b3_`i',beg,end) & inrange(b6_`i',212,304)
} Thank you, ZTH
... View more