Quantcast
Channel: Statalist
Viewing all articles
Browse latest Browse all 72762

Nested for loops

$
0
0
I would like some help with writing a nested for loop. So far this is what I have
foreach x of varlist A- J{
gen Share_`x' = 0
foreach y of varlist 1- 10{
replace Share_`x' = ( `y'/ `x')
}
}

What I want is to get 10 variables, each being '1/A', 2/B', '3/C' and so on. Right now this is giving me `1/A','2/A',`3/A'...
Is there a way to write the loop so I can get my desired result? Thank you!

Viewing all articles
Browse latest Browse all 72762

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>