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: Reference column without knowing variable name?


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

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/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index