Code:
clear
set obs 100
gen setA=0
gen setB=0
gen V1 = -1 + rnormal()
gen V2 = 1 + rnormal()
gen V1A = -.1 + rnormal()
gen V2A = .9 + rnormal()
gen V1B = .25
gen V2B = .25
foreach var in V1 V2 {
replace setA`i'=setA+`var'A
replace setB`i'=setB+`var'B
}
Could you explain me what this foreach loop is doing? I am simply not sure of how to interpet the part setA`i' ? What is the role of `i' in this example and is there a possible way to re-write this without the use of the foreach so I can try and pull it apart?
0 Response to Code Interpret Of Loop
Post a Comment