This should perhaps be obvious, but my searches are turning up too many unrelated items.
I used Stat/Transfer to convert a number of SPSS files to Stata files. I suppose because the variable names all have a long (and unnecessary) stem, they are stored as -note-s in the Stata dataset. I would like to loop over the variables, retrieve the -note- attached to each one, remove the stem, and then label the variable. Something like:
if such an extended macro function -note <varname> <note #> - existed. Given that it doesn't, is there a work around for capturing the note? I suppose I could log all variable notes, process it separately to produce a table of variable labels, then use that to relabel the variable list, but there should be an easier way. Is there?
J
I used Stat/Transfer to convert a number of SPSS files to Stata files. I suppose because the variable names all have a long (and unnecessary) stem, they are stored as -note-s in the Stata dataset. I would like to loop over the variables, retrieve the -note- attached to each one, remove the stem, and then label the variable. Something like:
Code:
foreach Q in varlist q_* {
local name : note `Q' 1
local name = subinstr("`name'","`stem'","",1)
label var `Q' "`name'"
}
J
Comment