Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's your best trick to break out of an unbalanced quote condition in BASE SAS?

Tags:

base

quotes

sas

As a base SAS programmer, you know the drill:

You submit your SAS code, which contains an unbalanced quote, so now you've got not only and unclosed quote, but also unclosed comments, macro function definitions, and a missing run; or quit; statement.

What's your best trick for not having those unbalanced quotes bother you?

like image 406
Martin Bøgelund Avatar asked Sep 20 '08 06:09

Martin Bøgelund


4 Answers

enterprise guide 3 used to put the following line at the top of its automatically generated code:

*';*";*/;run;

however, the only way to really "reset" from all kinds of something unbalanced problems is to quit the sas session, and balance whatever is unbalanced before re-submitting the code. Using this kind of quick (cheap?) hacks does not address the root cause.

by the way, ods _all_ close; closes all the ods destinations, including the default, results destination. in an interactive session, you should open it again with ods results; or ods results on; at least according to the documention. but when i tested it on my 9.2, it did not work, as shown below:

%put sysvlong=&sysvlong sysscpl=&sysscpl;
/* sysvlong=9.02.01M0P020508 sysscpl=X64_VSPRO */

ods _all_ close;
proc print data=sashelp.class;
run;
/* on log
WARNING: No output destinations active.
*/

ods results on;
proc print data=sashelp.class;
run;
/* on log
WARNING: No output destinations active.
*/
like image 73
Chang Chung Avatar answered Nov 11 '22 18:11

Chang Chung


As for myself, I usually Google for "SAS unbalanced quote", and end up with submitting something like this:

*); */; /*’*/ /*”*/; %mend;

... to break out of unclosed comments, quotes and macro functions.

like image 36
Martin Bøgelund Avatar answered Nov 11 '22 19:11

Martin Bøgelund


Here is the one I use.

 ;*';*";*/;quit;run;
 ODS _ALL_ CLOSE;
 QUIT; RUN;
like image 42
AFHood Avatar answered Nov 11 '22 20:11

AFHood


I had a situation with unbalanced quotes in a macro and the only solution was to close the instance of SAS and start over.

I feel that's an unacceptable flaw in SAS.

However, I used the methods by BOTH #2 and #5 and it worked. #2 first and then #1. I put them above ALL code, including my code header, explaining what this program was doing.

Worked like a charm.

like image 39
Sabby Avatar answered Nov 11 '22 20:11

Sabby