Statalist


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

st: AW: foreach commands


From   "Martin Weiss" <martin.weiss1@gmx.de>
To   <statalist@hsphsun2.harvard.edu>
Subject   st: AW: foreach commands
Date   Tue, 14 Apr 2009 16:30:02 +0200

<> 

One problem: The outer loop does not know your `x', so it does not know what
it is supposed to drop...



HTH
Martin


-----Ursprüngliche Nachricht-----
Von: owner-statalist@hsphsun2.harvard.edu
[mailto:owner-statalist@hsphsun2.harvard.edu] Im Auftrag von nigussie Tefera
Gesendet: Dienstag, 14. April 2009 16:20
An: statalist@hsphsun2.harvard.edu
Betreff: st: foreach commands

Dear stata list
I want to generate variables containing lnpindexprice11-lnpindexprice111 and
multiply them by wrfoodexpy11-wrfoodexpy111 and replace lnpindexprce*,
respectively. I used foreach commond as follows but it works only for the
first column i.e lnpindexprice11 but not for the other. Would you assist me
please

foreach w of varlist wrfoodexpy11- wrfoodexpy111 {
     foreach x of varlist pindexprice11-pindexprice111 {
     gen l`x'=ln(`x')
     gen lt`x'=l`x'*`w'
     }
drop `x'
}

Nigussie


      

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/


*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index