I am creating Event Files using DHS Contraceptive Calender data and I have been using the exact code given in the DHS module for STATA.
vcal_length is a string variable of length 80
forvalues j = vcal_len(-1)1 {
local `i' = vcal_len - `j' + 1
gen vcal1_i = substr(vcal_1,`j',1)
gen vcal2_i = substr(vcal_2,`j',1)
replace eps = eps+1 if vcal1_i != prev_vcal1
gen int ev004`i' = eps
replace prev_vcal1 = vcal1_`i'
}
It is still reading invalid syntax. Can anyone help me figure out the problem in the code?
vcal_length is a string variable of length 80
forvalues j = vcal_len(-1)1 {
local `i' = vcal_len - `j' + 1
gen vcal1_i = substr(vcal_1,`j',1)
gen vcal2_i = substr(vcal_2,`j',1)
replace eps = eps+1 if vcal1_i != prev_vcal1
gen int ev004`i' = eps
replace prev_vcal1 = vcal1_`i'
}
It is still reading invalid syntax. Can anyone help me figure out the problem in the code?