something like this:
foreach v1 of var math english other_acad {
foreach v2 of var first st {
tempvar `v1'X`v2'
g ``v1'X`v2'' = `v1'*`v2'
}
}
On Thu Mar 27 2003 17:08, Chris Rohlfs wrote:
> hi!
>
> i'm trying to make a loop to run statements like:
>
> qui gen `mathXfirst' = math*first
> qui gen `englishXfirst' = english*first
> qui gen `other_acadXfirst' = other_acad*first
>
> qui gen `mathXst' = math*st
> qui gen `englishXst' = english*st
> qui gen `other_acadXst' = other_acad*st
>
> where the first variable in each case is a tempvar name and hence inside
> quotation marks. is there a way to do something like:
>
> for C in var math english other_acad: for V in var first st: ...
>
> or something with foreach that will replace the V and C with variable
> names, even inside the quotation marks?
>
> thanks!
> chris
>
> *
> * 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/
--
Edwin Leuven
Department of Economics
University of Amsterdam
Phone: +31 (0)20 525 5241
Fax: +31 (0)20 525 4310
http://www1.fee.uva.nl/scholar/mdw/leuven
*
* 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/