DATA Step, Macro, Functions and more

Matching unbalanced quotes

Reply
New Contributor
Posts: 2

Matching unbalanced quotes

At one time I used to know a string of characters that you could submit that would match any unbalanced quotes and or comments in code that was submitted and needed the matching quote to stop running. It was something like */*'/*"/*/;run;

Does anyone know what it is? Thanks.
SAS Super FREQ
Posts: 8,864

Re: Matching unbalanced quotes

Hi:
The one I use is:
*'; *"; stop; run; quit; %mend;

which is a variation of the string recommended on page 15 of this document:
http://support.sas.com/publishing/pubcat/chaps/61025.pdf

I keep submitting it over and over until I see this message in the log, because, as it says on page 15:
"Depending on how deep a hole you have dug for yourself, you might need to run this line several times. You’ll know you’re done when you see an error message that says “No matching %MACRO statement for this %MEND statement.” The line works on unbalanced quotes because anything between an asterisk and the next semicolon is treated as a comment by SAS, unless there is an open quote, in which case it is just part of the quote. For example, *”; will close a double quote if one is open, but will not start a new quote."

cynthia
New Contributor
Posts: 2

Re: Matching unbalanced quotes

Thanks! That's exactly what I was looking for, but better.
Ask a Question
Discussion stats
  • 2 replies
  • 296 views
  • 0 likes
  • 2 in conversation