BookmarkSubscribeRSS Feed
sridatta
Calcite | Level 5

Hi Guys,

How to execute %include statements based on data set existence in each % include. If data set does not exist in current %include then program has to terminate and trigger a mail as job failure.

%include one;

%include two;

%include three;

%include four;

%include five;

%include six;

%include seven;

%include eight;

%include nine;

%include ten;

run;

Thanks for your suggestions.

3 REPLIES 3
art297
Opal | Level 21

You will get a more complete and probably better answer if you explain more about what you are trying to do, but you can always wrap your desired checks and logic into a macro.  e.g.:

%macro checkds;

  %let continue=1;

  %if %sysfunc(exist(work.test)) %then %do;

    %include "c:\art\include1.sas";

  %end;

  %else %do;

    %let continue=0;

  %end;

  %if &continue. and %sysfunc(exist(work.have)) %then %do;

    %include "c:\art\include2.sas";

  %end;

  %else %do;

    %let continue=0;

  %end;

  %if not(&continue) %then %do;

    data _null_;

      file print;

      put #3 @10 "Data set does not exist";

    run;

  %end;

%mend checkds;

%checkds

As for the code to send an email, take a look at: http://support.sas.com/kb/19/767.html

sridatta
Calcite | Level 5

In this program data is processing from one include statement to other include statement (i.e output of first include is an input for second include statement) and finally creates out files with correct data. If any one of the include statement doesn't run properly the final output files has not updated with correct data. so am looking for checkpoints at each include while executing the program.

art297
Opal | Level 21

Unless I misunderstand what you are trying to accomplish, that is what the suggested code does.  However, it was only written for 2 includes and you would have to expand it for however many you actually have.

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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