I want to use the user-written latab command which tabulates data in a latex table. Apparently, that command requires that all variable values have a label assigned. I have a variable that takes on lots of different values, so I don't want to assign the labels manually. Instead I thought I could just write in the variable value as the value label (which is obviously pointless, but it should make the latab command happy.)

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'"'
But the string label is not what I intend it to be and it also is quite confusing with the syntax. There must be an easier way to achieve this?