Dear all,
From the variable v I would like to generate 3 variables: v1, v2, v3. Given that these are the 3 observations of v. I need to make separate calculations with them, therefore I need to cut this variable as many times as its observations. Of course I can write:
gen v1 = v[1]
gen v2 = v[2]
gen v3 = v[3]
although I have more that 3 and therefore I look for a proper loop, I have tried the following:
forvalues i = 1/_n {
gen v`i'= v[_n-`i']
}
but it has a syntax error that I cannot fix. Generally whenever I enter `i' inside brackets in such commands I get an error. Could anyone suggest a solution or a different loop that I can use?
Thanks is advance,
Shadi
0 Response to generating separate variables from one variables's observations, is there a loop?
Post a Comment