You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
For each string in your program, determine whether it:
Can be enclosed with simple double quotes (e.g., the string Hello world)
Cannot be enclosed with simple double quotes, but can be enclosed with compound double quotes (e.g., "Hello world," he said.)
Cannot be enclosed with simple or compound quotes (e.g., Unbalanced "compound" double quotes`)
To manage and manipulate strings in category (3), use extended macro functions or Mata.
If a string is in category (1) or (2), but you don't know which, usually you have to treat it like (3). Remember that some quotes can be enclosed with simple double quotes but cannot be enclosed with compound double quotes, e.g. the simple case of ```.
The text was updated successfully, but these errors were encountered:
For the non-programmer, the most common time this comes up is with levelsof and other programs that always use compound double quotes to enclose values; I've gotten related support requests a few times. For example:
Also related -- though probably not worth mentioning in this module -- is my Mata function specialexp(), which converts a string to an expression that evaluates to the string:
ssc install specialexp
help specialexp
The help file contains examples of difficult strings.
One other point: replacing ``` with ' isn't guaranteed to work, because you still can't enclose unbalanced close compound double quotes with compound double quotes, i.e., `"'` has to be expressed as ``"""' + "'"`. If you're going to replace anything, perhaps better to replace double quotes. Then as long as you use the `macval()` expansion operator, I think you should be OK.
Start with
help quotes
.For each string in your program, determine whether it:
Hello world
)"Hello world," he said.
)Unbalanced
"compound" double quotes`)To manage and manipulate strings in category (3), use extended macro functions or Mata.
If a string is in category (1) or (2), but you don't know which, usually you have to treat it like (3). Remember that some quotes can be enclosed with simple double quotes but cannot be enclosed with compound double quotes, e.g. the simple case of ```.
The text was updated successfully, but these errors were encountered: