Hi all,
I am trying to run many SAS programs by using below macro. I have not defined path of program since they are present in same folder where I am running macro:
%macro run_check(prg);
proc printto log="&prg.log";
run;
proc printto print="&prg.lst";
run;
%include "&prg.sas";
%mend;
options symbolgen merror mlogic;
%run_check(SD0036.);
But it shows below ERROR in log file of SD0036.sas:
WARNING: Physical file does not exist, XXXXXXX/SD0036.sas.
ERROR: Cannot open %INCLUDE file SD0036.sas.
I am not sure why 'Dot' comes after 'SD0036.sas' name in log.
Please let me now how to fix this issue.
Thank you.
You need to specify in the %include what folder your program is stored in. For example
%include "G:\team1\project2\mysasprogram.sas";
You need to specify in the %include what folder your program is stored in. For example
%include "G:\team1\project2\mysasprogram.sas";
My bad. My program name is "sd0036.sas', I was writing 'SD0036.sas'.
Sorry for any inconvenience.
@petlove wrote:
My bad. My program name is "sd0036.sas', I was writing 'SD0036.sas'.
Sorry for any inconvenience.
It sounds like you have mis-understood the entire set of comments. The capitalization of your program name is not the problem. The problem is that you need to put the full folder path and file name in your %INCLUDE.
Without mentioning full folder path also program runs successfully. Since location of my program sd0036.sas and macro %run_check is same on Unix.
If macro is in different location then only I will need to specify the full path in %include.
I did run program without full path and it ran successfully and created .log and .lst file for sd0036.sas.
The SAS documentation actually includes an example with relative path (see Example 1): http://documentation.sas.com/?cdcId=pgmsascdc&cdcVersion=9.4_3.4&docsetId=lestmtsglobal&docsetTarget...
But be careful when using relative path, they are normally relative to the working path which is not necessarily the same as the path where the current program is stored. So in some context, relative paths can lead to unexpected behaviors.
@petlove wrote:
I did run program without full path and it ran successfully and created .log and .lst file for sd0036.sas.
See this as an example of "works by accident". ALWAYS use absolute path names when working on UNIX.
cd /sas/programs sas myprog.sas
will run with a current working directory of /sas/programs, while
cd sas /sas/programs/myprog.sas
will run with your home directory as CWD. Relative path names are always resolved from the CWD, so you will get different results.
The dot is simple punctuation, properly formed sentences end with a dot.
Does SAS really print XXXXXX as the path or did you hide it yourself?
Are you sure the "working path" is really where you expect it to be?
Remember to specify the full path along with the .sas filename
HI all,
I am trying to run multiple programs without calling %run_check for each dataset manually. I have create another macro with do loop.:
%macro run_check(dsn);
proc printto log="&dsn.log";
run;
proc printto print="&dsn.lst";
run;
%include "&dsn.sas";
%mend;
%macro prgrun;
%let dqclist=sd1044#sd1131#sd1121;
%do i= 1 %to %eval(%sysfunc(count(&dqclist,#))+1);
%let dqc=%scan(&dqclist,&i,#);
%run_check(/u1/stat/dqc/XXXX/prog/&dqc..);
%end;
%mend;
options symbolgen mlogic merror serror;
%prgrun;
I was expecting to run all 3 programs sd1044, sd1131 and sd1121. However, I see that only first program in the loop runs i.e. sd1044.
Can you please take look at it? Not sure why other 2 programs don't run?
Thank you.
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.