Thanks Nick and Edwin.
You're among the best.
Amadou.
"Nick Cox"
<[email protected]> To: <[email protected]>
Sent by: cc:
owner-statalist@hsphsun2. Subject: st: RE: Nested loops?
harvard.edu
09/21/2004 10:15 AM
Please respond to
statalist
local varlist "v1 v2 v3 v4 v5 v6 v7 v8"
tokenize "`varlist'"
local nv : word count `varlist'
forval j = 1/`nv' {
forval i = 2/`nv' {
if `i' > `j' gen ``i''_``j'' = ``i'' * ``j''
}
}
Nick
[email protected]
[email protected]
> I would like to generate the following variables:
>
> local myvars "v1 v2 v3 v4 v5 v6 v7 v8....etc..."
>
> for var v2 v3 v4....: g X_v1 = X*v1
> for var v3 v4 v5 v6...: g X_v2 = X*v2
> for var v4 v5 v6 v7... g X_v3 = X*v3
> etc.
>
> How to do that, if I have a lot of variables involved?
*
* For searches and help try:
* http://www.stata.com/support/faqs/res/findit.html
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/
*
* For searches and help try:
* http://www.stata.com/support/faqs/res/findit.html
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/