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.

 

 

 

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

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