Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: st: foreach loop over all variables
From
John Antonakis <[email protected]>
To
[email protected]
Subject
Re: st: foreach loop over all variables
Date
Sat, 25 Feb 2012 15:32:59 +0100
Right. To be more specific,
For example, suppose you wish to standardize all the variables. You'd do:
foreach var of varlist q1-q5 {
egen std`var'=std(`var')
}
HTH,
John.
__________________________________________
Prof. John Antonakis
Faculty of Business and Economics
Department of Organizational Behavior
University of Lausanne
Internef #618
CH-1015 Lausanne-Dorigny
Switzerland
Tel ++41 (0)21 692-3438
Fax ++41 (0)21 692-3305
http://www.hec.unil.ch/people/jantonakis
Associate Editor
The Leadership Quarterly
__________________________________________
On 23.02.2012 10:34, Benjamin Volland wrote:
the following worked for me:
foreach var of varlist * {
....
}
Best,
Benjamin Volland
On 23/02/2012 10:31, Seliger Florian wrote:
Dear Statalist,
Maybe that's a silly question, but Google didn't give any answers:
I want to create a loop with foreach over ALL variables in a dataset,
foreach ALL VARIABLES {
...
}
It is not possible to write
foreach var1-var100
because the number and names of the variables vary from dataset to
dataset and the do-file has to work for any dataset without making
any changes.
Thanks a lot.
Best wishes,
__________
Florian Seliger
Researcher
ETH Zurich
KOF Swiss Economic Institute
WEH C 5
Weinbergstrasse 35
8092 Zurich, Switzerland
[email protected]
www.kof.ethz.ch
+41 44 632 37 17 phone
+41 44 632 12 18 fax
*
* 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/
*
* 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/