I want to write 6 temp data files from my original data keeping the following variables:
- temp1: v1-v18
- temp2: v1-v5 v19-v31
- temp3: v1-v5 v32-v44
- temp4: v1-v5 v45-v57
- temp5: v1-v5 v58-v70
- temp6: v1-v5 v71-v84
I tried the following:
forvalues i =1(1)6{ preserve
local j = 6 + (`i'-1)*13
local k = `j'+12
keep v1-v18 if `j'==6
keep v1-v5 v`i'-v`k' if `i'>6 & `j'<71
keep v1-v5 v71-v84 if `j'==71
export delimited using temp`i'.csv, delimiter(";") novarnames replace
restore }
(sorry for the layout. I am a first timer here)
I get an invalid syntax error. The problem lies with the keep statements. Specifically the if condition with a local macro seem to be against syntax rules. Please help
Aucun commentaire:
Enregistrer un commentaire