So say the variable takes on the value 1234, then I would like to label the variable with a value label of 1234 via >label define value_label 1234 "1234"<. I thought I could do it like this:
Code:
clear all
set obs 100
set seed 1234
g x = round(rnormal(5,10))
local label_string=""
levelsof x, local(values)
foreach value in "`values'" {
local label_string = "`label_string'" + " " + "`value'" + " " + `""`value'""'
}
dis `"`label_string'"'
label define value_label `"`label_string'"'
label values x value_label
// this seems to work:
local j = "xxx"
local i = `""`j'""'
dis `"`i'"'
0 Response to Value labels for variable with lots of different values
Post a Comment