Hi,
I've been reading about local/global macro resolution in Stata. My question relates to this document https://www.stata.com/manuals/pmacro.pdf, header "Macro assignment" and text
"
The compound double quotes (‘” and ”’) are needed when something itself contains quotation marks. In fact, if the string is anything more complex than a single word, it is safest to enclose the string in compound quotes (‘” ”’). The outermost compound quotes will be stripped, and all that remains will be assigned to name. Note that any embedded macro references in something are expanded before assignment to name whether or not compound quotes are used
"
On this basis, I understand that the code
Would mean that the macro file contains "C:/Users..." (quotes not to be ignored)
Therefore, I would presume that code below would work...
but it doesn't. It returns "C: invalid name"
I find this confusing because the code below does work
What's wrong? Based on the error, it seems that the command display also unresolves the quotes from file and thinks that it is a variable or something. I suspect this because even the former, hard-coded command only prints C:/Users... and does not include the quotes.
Thank you for helping.
I've been reading about local/global macro resolution in Stata. My question relates to this document https://www.stata.com/manuals/pmacro.pdf, header "Macro assignment" and text
"
The compound double quotes (‘” and ”’) are needed when something itself contains quotation marks. In fact, if the string is anything more complex than a single word, it is safest to enclose the string in compound quotes (‘” ”’). The outermost compound quotes will be stripped, and all that remains will be assigned to name. Note that any embedded macro references in something are expanded before assignment to name whether or not compound quotes are used
"
On this basis, I understand that the code
Code:
local file `"C:/Users..."'
Therefore, I would presume that code below would work...
Code:
display `file'
I find this confusing because the code below does work
Code:
display "C:/Users..." [Output:] C:/Users...
Thank you for helping.
Comment