Statalist The Stata Listserver


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

Re: st: RE: accessing a variable's value WRT its attached value label


From   "Michael Blasnik" <michael.blasnik@verizon.net>
To   <statalist@hsphsun2.harvard.edu>
Subject   Re: st: RE: accessing a variable's value WRT its attached value label
Date   Thu, 30 Mar 2006 09:01:03 -0500

"Phil Schumm" <pschumm@uchicago.edu> wrote:
<snip>
I guess what I was really trying to avoid was the inline expansion of an extended macro function; in my experience, many users find this a much bigger jump than just learning how to use a simple macro (e.g., within a -foreach- loop). This is especially true with the second colon and/or if you throw in additional levels of nesting, e.g.

foreach var of varlist var1 var2 ... {
count if `var' == "yes":`:val l `var''
}
Why not just expand the macro on a separate line?
foreach var of varlist var1 var2 ... {
local valuelabel: value label `var'
count if `var' == "yes":`valuelabel'
}

Michael Blasnik
michael.blasnik@verizon.net
*
* 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–2020 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index