Hi,
Can anyone suggest how to exit from program in case file does not exit. I have some other include statement, based on file existance, I need to proceed to next program call.
filename ip_file '&ip_folder.\&file.';
%if (%sysfunc(fexist(ip_file)) eq 0) %then %do;
%put ERROR: Physical file does not exist ==> &ip_folder.\&file. ;
%end;
%include "someother program/abcd.sas";
This
filename ip_file '&ip_folder.\&file.';
will fail because macro triggers do not resolve within single quotes.
You can use the FILEEXIST Function with the physical filename, so you can omit the FILENAME anyway. And you can test for existence, run the include, and put the message otherwise:
%if %sysfunc(fileexist(&ip_folder.\&file.)) %then %do;
%include "someother program/abcd.sas";
%end;
%else %do;
%put ERROR: Physical file does not exist ==> &ip_folder.\&file. ;
%end;
This
filename ip_file '&ip_folder.\&file.';
will fail because macro triggers do not resolve within single quotes.
You can use the FILEEXIST Function with the physical filename, so you can omit the FILENAME anyway. And you can test for existence, run the include, and put the message otherwise:
%if %sysfunc(fileexist(&ip_folder.\&file.)) %then %do;
%include "someother program/abcd.sas";
%end;
%else %do;
%put ERROR: Physical file does not exist ==> &ip_folder.\&file. ;
%end;
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.