Hi, I needed help with the syntax of converting cognitive raw scores of the cognitive test (PPVT) with reference to the Young Lives data Round 2 (attached).
Attached is the do file also.


Preview attachment R2 to use_working8.12.20.dta



R2 to use_working8.12.20.dtaPreview attachment DF_PPVT score key2(revised2).do



DF_PPVT score key2(revised2).do
3.7 KB
5 MB
I tried the following syntax but it's showing an error.
Syntax: Generating answer codes for all items ( 1 to 204 )
gen ans_1=4
gen ans_2=3
gen ans_3=1

gen ans_201=4
gen ans_202=2
gen ans_203=3
gen ans_204=2
mvdecode ppvt1 - ppvt204, mv(77 79 88 99)
forval i = 1/204 {
replace ppvt`i' = 0 if ppvt`i'!=ans_`i' & ppvt`i'!=.
replace ppvt`i' = 1 if ppvt`i'==ans_`i'
}


Thank you.