Use extended macro functions. Here is one example:
clear all
set more off
sysuse auto
forvalues i = 0/1 {
local t : label origin `i'
display "`t'"
twoway scatter mpg weight if foreign == `i', title("`t'")
}
origin
is the name of the value label associated with the variable foreign
. You can list the names and contents of all value labels using label list
.
The line local t : label origin `i'
retrieves the label for the value in macro i
, and assigns it to the macro t
. Then you can use macro t
as you wish.
See help label
, help macro
and help extended_fcn
.