Statalist


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: generating new variables: any shortcut?


From   "Sebastian F. B�chte" <[email protected]>
To   [email protected]
Subject   Re: st: generating new variables: any shortcut?
Date   Tue, 10 Jul 2007 11:21:57 +0200

You could try -foreach-:

foreach elem of varlist var1-var15 {
     gen log_`elem' = log(`elem')
}

hth
Sebastian

On 7/10/07, Vladimir V. Dashkeyev <[email protected]> wrote:
Dear all,

I want to create new variables by taking logarithms of old variables
and I want to keep old names:

-- gen log_var1 = log(var1) --

If I need to take logs of all the variables in the dataset or at least
of the variables that are named consequently (e.g. var1,
var2...var15), is there a way to generate new variables by a single
command?

Thanks in advance,
Vladimir.
*
*   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/



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