BookmarkSubscribeRSS Feed
SASdevAnneMarie
Barite | Level 11

Hello Experts,

 

I'm coding in SAS EG, I would like to stop the execution of my program if I have 0 rows in my data. Do you know some option to do that please ?

 

I mean thant in my EG projet I have 3 programs : firstly I run the pgm_1, after the pgm_2 and the pgm_3.

I would like to put the code in pgm_1, and stop the pgm_2 and pgm_3 if _n_=0 (I run the program by order list). I don't know if it's possible in EG.

My code is: 

proc sql noprint;
	select count(*) into :nb from PRRT;
quit; 

%if &nb=0 %then
	%do;
        STOP ?
	%end;

Thank you very much !

2 REPLIES 2
Amir
PROC Star

Hi @SASdevAnneMarie ,

 

Have you tried looking into the abort statement? The documentation can be found here.

 

 

Kind regards,

Amir.

LeonidBatkhan
Lapis Lazuli | Level 10

Hi MarieT,

 

You can do it this way, for example:

 

%if &nb=0 %then
%do;
   data _null_;
      abort return;
   run;
%end;

See ABORT Statement.

Hope this helps.

 

 

 

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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
  • 2 replies
  • 615 views
  • 2 likes
  • 3 in conversation