BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
DavidPhillips2
Rhodochrosite | Level 12

I'm trying to pass the string and gender="F" and tenure in ("01","02"). In this example the macro does nouthing. Something about passing the string is causing an error. An error message does not occur the first time I run the script to see an error message I have to run just the last line with run selection a second time. I can run
%turnoverTable(faculty, %str() );
%turnoverTable(faculty, %str(and tenure in ('01','02')) );

but not
%turnoverTable(faculty, %str(and gender="F" and tenure in ("01","02") );

%macro turnoverTable(tableName, additionalWhereClause);
/*do nouthing*/
%mend;

/*these work*/
%turnoverTable(faculty, %str() );
%turnoverTable(faculty, %str(and tenure in ('01','02')) );
/*this causes the error*/ /*I run it a second time to see the log blow up to see the erorr you have to run this line again using run selection*/ %turnoverTable(faculty, %str(and gender="F" and tenure in ("01","02") );

;*';*";*/;quit;run;
2 OPTIONS PAGENO=MIN;
3 %LET _CLIENTTASKLABEL='Program';
4 %LET _CLIENTPROCESSFLOWNAME='Process Flow';
5 %LET _CLIENTPROJECTPATH='';
6 %LET _CLIENTPROJECTPATHHOST='';
7 %LET _CLIENTPROJECTNAME='';
8 %LET _SASPROGRAMFILE='';
9 %LET _SASPROGRAMFILEHOST='';
10
11 ODS _ALL_ CLOSE;
12 OPTIONS DEV=PNG;

_________________________________
49
NOTE 49-169: The meaning of an identifier after a quoted string might change in a future SAS release. Inserting white space
between a quoted string and the succeeding identifier is recommended.

13 GOPTIONS XPIXELS=0 YPIXELS=0;
14 FILENAME EGSR TEMP;
15 ODS tagsets.sasreport13(ID=EGSR) FILE=EGSR
16 STYLE=VCU_Report_Printing
17 STYLESHEET=(URL="redacted")
18 NOGTITLE
19 NOGFOOTNOTE
20 GPATH=&sasworklocation
21 ENCODING=UTF8
NOTE: Line generated by the macro variable "SASWORKLOCATION".
21 ") NOGTITLE NOGFOOTNOTE
21 ! GPATH="/saswork/SAS_workF1AB0000291E_redacted/SAS_work29A50000291E_redacted/"

_____________________________________

1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

Unbalanced ()

%turnoverTable(faculty, %str(and gender="F" and tenure in ("01","02") );

has three ( and only two )    the second ) closes the %str function so you do not have a close for the parameter list.

%turnoverTable(faculty, %str(and gender="F" and tenure in ("01","02") )  );

 

The editor should have a find matching parentheses function

View solution in original post

3 REPLIES 3
ballardw
Super User

Unbalanced ()

%turnoverTable(faculty, %str(and gender="F" and tenure in ("01","02") );

has three ( and only two )    the second ) closes the %str function so you do not have a close for the parameter list.

%turnoverTable(faculty, %str(and gender="F" and tenure in ("01","02") )  );

 

The editor should have a find matching parentheses function

DavidPhillips2
Rhodochrosite | Level 12

Thanks, Ballardw oddly the editor did not catch the unbalanced parameters.  This solved the issue though.

ballardw
Super User

@DavidPhillips2 wrote:

Thanks, Ballardw oddly the editor did not catch the unbalanced parameters.  This solved the issue though.


It isn't an automatic function. You place the cursor on a ( and then with the proper key it should find the match. In the SAS Display Manger that is Ctrl+( or Ctrl+) keys. Hold Ctrl and press either of the ( or ) and the cursor moves to the matching key (and back, doesn't matter which of the () that you use). If it doesn't move then there isn't a match.

 

Because of the basic approach SAS has to code and especially with the macro language there can't really be a syntax check prior to submission for some forms of missmatched () and/or quotes.

sas-innovate-wordmark-2025-midnight.png

Register Today!

Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.


Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 830 views
  • 0 likes
  • 2 in conversation