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

Re: st: dump variable label value into local macro??


From   Phil Schumm <[email protected]>
To   [email protected]
Subject   Re: st: dump variable label value into local macro??
Date   Tue, 15 Nov 2005 11:40:51 -0600

On Nov 15, 2005, at 11:17 AM, [email protected] wrote:
I am -forvalue-ing across values of a categorical variable w/ nine unique values and generating a graph for each unique value of this variable. This variable is numeric and i've attached a label to each value of this variable via -label define- and -label values-. When generating the graphs, I would like to use the -subtitle- option to denote which level of the categorical variable is being graphed, albeit i want the actual label value written to the graph, not the value of the macro. The abbreviated syntax follows:

local i = 1
forvalues i = 1(1)9 {
gr hbar (mean) mean_abs_error mean_error_to_itd count_abs_error if
segment2==`i' , ///
subtitle("`i'") legend(off) ytitle("Absolute Error, Relative Error, &
Project Num.") ///
graph export m_error`i'.pdf, replace
local i = `i' + 1
}

Replacing subtitle("`i'") with subtitle("`:lab (segment2) `i''") should give you what you want. This uses the macro extended function -label- together with the `:extended_fcn' construct for inline access to macro extended functions. See [P] macro (or -help macro-) for more details.


-- Phil

*
* 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