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

unabbreviating varlists [was: RE: st: A tricky graph to make]


From   "Nick Cox" <[email protected]>
To   <[email protected]>
Subject   unabbreviating varlists [was: RE: st: A tricky graph to make]
Date   Wed, 15 Oct 2003 10:48:51 +0100

Dimitriy V. Masterov included this code 
fragment in his answer to a graphical question, 
which I have commented on separately. (I've 
edited out details irrelevant to the point I'm 
going to make.)  

local list score*
unab list: `list'
local graph ""
 
foreach var of varlist `list' {
 	local graph "`graph' (line `var' year, sort) "
}

In essence this could be telescoped once 

unab list: score* 
local graph ""
 
foreach var of varlist `list' {
 	local graph "`graph' (line `var' year, sort) "
}

and indeed twice 

local graph "" 
foreach var of varlist score* {  
 	local graph "`graph' (line `var' year, sort) "
}

The -foreach- loop can work directly on a wildcarded
list. 

Nick
[email protected] 
*
*   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