BookmarkSubscribeRSS Feed
learning_one
Calcite | Level 5

Hello,  I`` trying to make it so a second query will only start depending on the result of a second query using %sysfunc macro.
I'm getting an error message saying a parenthesis is required, but there is one so I do not understands.

 

Using SAS Enterprise Guide Version 8.2

 

Here's a copy of the log:
184
185 %let Result_of_sys_check = %sysfunc(sql, SELECT count(warning_ind) FROM work.warning_check WHERE warning_ind = 1);
ERROR: Expected open parenthesis after macro function name not found.
186 %if &Result_of_sys_check > 0 %then %do;
ERROR: Required operator not found in expression: SELECT count(warning_ind) FROM work.warning_check WHERE warning_ind = 1) > 0
ERROR: Skipping to next %END statement.
187

2 REPLIES 2
ballardw
Super User

%sysfunc is designed to make data step functions available to the macro language.

As such %syfucnt expects to see as the first element the name of a function which would typically have a () around the parameters the function uses.

 

%sysfunc (somefunctionname(<parameter list for the function goes here>) )

 

Your syntax has SAS thinking there should be an open parenthesis character, (, immediately after SQL.

 

I'm not sure that SQL qualifies as a FUNCTION. I think you may want something more like:

proc sql noprint;
   SELECT count(warning_ind) into : Result_of_sys_check
   FROM work.warning_check 
   WHERE warning_ind = 1
;
quit;

The INTO : writes the result of the Count function into a macro variable named Result_of_sys_check.

 

learning_one
Calcite | Level 5

Thank you