Bookmark and Share

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]

st: AW: AW: Reference column without knowing variable name?


From   "Martin Weiss" <[email protected]>
To   <[email protected]>
Subject   st: AW: AW: Reference column without knowing variable name?
Date   Wed, 3 Mar 2010 10:50:09 +0100

<> 

" ds (resp. ds2 or ds3) is great to list vars based on different attributes but not necessary here because you can use "*" or "_all"."


That depends on the kind of transformation you have in mind. If it applies to all vars without exception, then this is a viable strategy. Most of the time, you want separate things done to strings and numeric vars, though...




HTH
Martin


-----Ursprüngliche Nachricht-----
Von: [email protected] [mailto:[email protected]] Im Auftrag von [email protected]
Gesendet: Mittwoch, 3. März 2010 10:40
An: [email protected]
Betreff: st: AW: Reference column without knowing variable name?

Martins solution is perfectly right. 
I want to add a very basic solution. 

What you need for that task is 
- a macro with all vars to cycle through and 
- an index to decide if the actual var should be altered or not. 

ds (resp. ds2 or ds3) is great to list vars based on different attributes but not necessary here because you can use "*" or "_all". 

foreach var of varlist * {
local i = `i' + 1
if mod(`i'-1,3)== 0 rename `var' yes__`var'
}


Local i counts the loops/variables processed. 
mod(`i',3) is 0 for i = 0,3,6,9,...
=> mod(`i'-1,3) is 0 for `i' = 1,4,7,...


Stefan Gawrich








*
*   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–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index