Hello all,
I have been struggling with this for some time and would appreciate any advice. I checked prior statalist posts https://www.stata.com/statalist/arch.../msg01071.html and https://www.stata.com/statalist/arch.../msg00463.html, but have not fully figured this one out.
Essentially, I want to create a local macro and add to it iteratively. Seems relatively straightforward, except that I need each argument to be in quotes (" ") in the final version of the local.
My naive first attempt was
which led to the output
But I was not to be deterred. I had seen on other posts that I can "protect" quotation marks by compounding them with `', so I tried
which led to the output
Putting quotation marks around references to the local didn't seem to help
since I got the output
Which is interesting, but still not it. Putting extra single quotes around references to local `this' led to no quotation marks shown at all (no matter how I put quotes around the items being added to the local). I tried one final thing:
which led to the output
Again, not it. There must be some way of doing this - I just can't seem to get the quotes right! Just for clarity, I would like to be iteratively adding a new item in quotation marks, such that the final list reads
Any suggestions would be greatly appreciated!
I have been struggling with this for some time and would appreciate any advice. I checked prior statalist posts https://www.stata.com/statalist/arch.../msg01071.html and https://www.stata.com/statalist/arch.../msg00463.html, but have not fully figured this one out.
Essentially, I want to create a local macro and add to it iteratively. Seems relatively straightforward, except that I need each argument to be in quotes (" ") in the final version of the local.
My naive first attempt was
Code:
local this local this `this' "that" local this `this' "the other" display `"`this'"'
Code:
that "the other"
But I was not to be deterred. I had seen on other posts that I can "protect" quotation marks by compounding them with `', so I tried
Code:
local this local this `this' `"that"' local this `this' `"the other"' display `"`this'"'
Code:
that `"the other"'
Putting quotation marks around references to the local didn't seem to help
Code:
local this local this "`this'" "that" local this "`this'" "the other" display `"`this'"'
Code:
" "that" "the other
Which is interesting, but still not it. Putting extra single quotes around references to local `this' led to no quotation marks shown at all (no matter how I put quotes around the items being added to the local). I tried one final thing:
Code:
local this local this `"`this'"' `"that"' local this `"`this'"' `"the other"' display `"`this'"'
Code:
thatthe other
Again, not it. There must be some way of doing this - I just can't seem to get the quotes right! Just for clarity, I would like to be iteratively adding a new item in quotation marks, such that the final list reads
Code:
"that" "the other"
Comment