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;
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
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.
Ready to level-up your skills? Choose your own adventure.