Hi Everyone,
I have a situation where I need to run different data step based on output from 1st PROC SQL. I was looking for GOTO statement but it will not help because it needs to be used inside one data step.
PROC SQL
query to get the details from DB2 table.
QUIT;
DATA _NULL_;
if &sqlobs = 0
I need to bypass below proc steps and execute the code from label XXXX
run;
proc sort data=xxx;
run;
proc SQL
another query to get data from DB2
quit;
DATA ABCD;
SET AAAA ( KEEP=XX,YY,ZZ,...);
few logics here..
run;
XXXX:
proc SQL
get data from DB2 table for another processing
quit;
proc print;
...
...
Any suggestion will be really helpful.
Thank you
pk
You need a macro 😞 But, it's a pretty basic one.
Here's a fully worked example that is from the SAS documentation. It checks if a data set has observations and prints it or otherwise prints a message to the log.
It's fully explained so its a good starting point. But, if you have any further questions, feel free to post back.
Full list of macros in the appendix (for reference):https://communities.sas.com/t5/SAS-Communities-Library/SAS-9-4-Macro-Language-Reference-Has-a-New-Ap...
@batu544 wrote:
Hi Everyone,
I have a situation where I need to run different data step based on output from 1st PROC SQL. I was looking for GOTO statement but it will not help because it needs to be used inside one data step.
PROC SQL query to get the details from DB2 table. QUIT; DATA _NULL_; if &sqlobs = 0 I need to bypass below proc steps and execute the code from label XXXX run; proc sort data=xxx; run; proc SQL another query to get data from DB2 quit;
DATA ABCD;
SET AAAA ( KEEP=XX,YY,ZZ,...);
few logics here.. run;
XXXX: proc SQL get data from DB2 table for another processing quit; proc print; ... ...Any suggestion will be really helpful.
Thank you
pk
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.