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

st: RE: Extended Function Macro's in Foreach: `: variable label `v''wrong?


From   "Scott Merryman" <smerryman@kc.rr.com>
To   <statalist@hsphsun2.harvard.edu>
Subject   st: RE: Extended Function Macro's in Foreach: `: variable label `v''wrong?
Date   Sun, 15 May 2005 16:03:15 -0500

How about defining the local macro before the -graph box-

Something like:

foreach v of varlist mpg price weight {
	local title :variable label `v'
      graph box `v' , title(`title') name(`v')
}

Scott


> -----Original Message-----
> From: owner-statalist@hsphsun2.harvard.edu [mailto:owner-
> statalist@hsphsun2.harvard.edu] On Behalf Of Orion Whitaker
> Sent: Sunday, May 15, 2005 10:58 AM
> To: statalist@hsphsun2.harvard.edu
> Subject: st: Extended Function Macro's in Foreach: `: variable label
> `v''wrong?
> 
> I would like to label plots with the variables -label- using extended
> functions in a 'foreach' loop.
> 
> Somehow this code does not give a title to the graph:
> 
>    foreach v of varlist age {
>       display "`v'"
>       graph box `v' , title(" ` : variable label `v' ' ")
>       //  that's  dq lsq : variable label rlq v rsq rsq dq
>       // as in dq: double quote   lsq:  left single quote
>       }
> 
> I'm perplexed as I tried to 'mirror' code that worked for 'display',
> namely
>    display " `var' "  _col(20)  "`" type `var''"
> 
> Suggestions?
> 
> 
> --
> Orion C. Whitaker
> Johns Hopkins School of Public Health
> Johns Hopkins School of Medicine
> owhitak1@jhmi.edu
> *
> *   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/


*
*   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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index