Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: Adding new variables to an existing global macro listof variables.


From   "Dev Vencappa" <lexdvv@nottingham.ac.uk>
To   <statalist@hsphsun2.harvard.edu>
Subject   Re: st: Adding new variables to an existing global macro listof variables.
Date   Fri, 06 Aug 2004 18:24:49 +0100

>>>
>>>

Stata users, 
 is there a way to create a global list of variables that starts empty and successively adds new variables to the list as they are created? I am trying to write something like:

use "C:\XYZ.dta",clear

global Xlist

foreach var of varlist lntoen lncap lntech lndebt{
sum `var'
gen mean`var'=r(mean)
global (add the newly created variable mean`var' to $Xlist)
}

*then take the minimum of all these variables
egen Y=min($Xlist)

The reason I am trying to use a macro is because I have to create many variables and use the one that has the lowest value. This has to be done within a loop for each of several years.

Any alternative approach to mine would be really appreciated.


Many thanks

Dev





This message has been scanned but we cannot guarantee that it and any
attachments are free from viruses or other damaging content: you are
advised to perform your own checks.  Email communications with the
University of Nottingham may be monitored as permitted by UK legislation.


*
*   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/



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