BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
petlove
Obsidian | Level 7

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.

1 ACCEPTED SOLUTION

Accepted Solutions
PaigeMiller
Diamond | Level 26

You need to specify in the %include what folder your program is stored in. For example

 

%include "G:\team1\project2\mysasprogram.sas";
--
Paige Miller

View solution in original post

9 REPLIES 9
PaigeMiller
Diamond | Level 26

You need to specify in the %include what folder your program is stored in. For example

 

%include "G:\team1\project2\mysasprogram.sas";
--
Paige Miller
petlove
Obsidian | Level 7

My bad. My program name is "sd0036.sas', I was writing 'SD0036.sas'.

 

Sorry for any inconvenience.

 

PaigeMiller
Diamond | Level 26

@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.

--
Paige Miller
petlove
Obsidian | Level 7

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.

ybolduc
Quartz | Level 8

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.

Kurt_Bremser
Super User

@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.

ybolduc
Quartz | Level 8

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?

PeterClemmensen
Tourmaline | Level 20

Remember to specify the full path along with the .sas filename

petlove
Obsidian | Level 7

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.

 

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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
  • 9 replies
  • 4205 views
  • 3 likes
  • 5 in conversation