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;
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
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.