I have read probably a dozen different people's answers on this topic and tried a dozen different versions of this code but for whatever reason I cannot make the compound quotes work properly.
The goal is to create a global variable (could be a local variable, it doesn't matter that much to me) that I can sub in nicely in front of label var. Let me give you the full code first:
The key is that I want the code near the bottom
To read this on the first loop:
I may have done the last part wrong too, but it's irrelevant right now because:
Returns the following error:
The first compound quote seems to work, but the second one doesn't. I am completely stumped. How do I get it so I get quotations surrounding the value of varlab?
Thanks,
Jonathan
The goal is to create a global variable (could be a local variable, it doesn't matter that much to me) that I can sub in nicely in front of label var. Let me give you the full code first:
Code:
sysuse auto, clear
describe, replace
forval i=1/7 {
local j=name in `i'
di "`j'"
local k=varlab in `i'
local kq=`"""' "`k'" `"""'
di `kq'
global vlab`i' "`j'" "`kq'"
}
sysuse auto, clear
forval i=1/7 {
label var "${vlab`i'}"
}
Code:
label var "${vlab`i'}"
Code:
label var "${vlab`i'}"
I may have done the last part wrong too, but it's irrelevant right now because:
Code:
sysuse auto, clear
describe, replace
forval i=1/7 {
local j=name in `i'
di "`j'"
local k=varlab in `i'
local kq=`"""' "`k'" `"""'
di `kq'
global vlab`i' "`j'" "`kq'"
}
invalid '"Make and Model'
Thanks,
Jonathan

Comment