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

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 2 replies
  • 1297 views
  • 0 likes
  • 2 in conversation