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
Related Posts with generating separate variables from one variables's observations, is there a loop?
Ordinal regression with random factorsI'm try to run an ordinal regression with random factors. I'm using the meologit command. My depende…
overlaying two hazard rate plotsDear All, Suppose that I compute the following hazard rates (unfortunately I cannot share the real d…
error correction model with rolling regressionHello. I am trying to do error correction model with rolling regression. here. I want to change the …
Multiple subgroup meta-analysisGood evening, I want to do a meta-analysis of multiple subgroups. Code: * Example generated by -da…
How to replace value of a variable in one round with its value in a previous round ?Hi all, Please consider the following sample data Code: * Example generated by -dataex-. To insta…
Subscribe to:
Post Comments (Atom)
0 Response to generating separate variables from one variables's observations, is there a loop?
Post a Comment