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-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 2 replies
  • 488 views
  • 2 likes
  • 3 in conversation