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

How to run multiple SAS programs from one single SAS program. A log file should also be created for each SAS program

1 ACCEPTED SOLUTION

Accepted Solutions
Astounding
PROC Star

Yes, it absolutely does that.  If you want the output as well as the logs to be moved, you need to add to the macro:

 

%macro run_one (path);

   proc printto log="&path.log";

   run;

   proc printto print="&path.lst";

   run;

   %include "&path.sas";

   run;

%mend run_one;

View solution in original post

9 REPLIES 9
LinusH
Tourmaline | Level 20

Why?

If your requirement is separated logs, it's easier to call those programs in an external shell/dos script instead.

Data never sleeps
Astounding
PROC Star

Where should the logs go?  What should they be named?

KBACHU
Fluorite | Level 6

Logs should be created at the same location as programs and should be named as programs. I tried running the below test.sas code in which I included multiple SAS programs, but it doesnt create the log files separately instead writing everything to test.log file. I would like to have the log files created for each SAS program, something like test2.log, test3.log, test4.log

 

Content of test.sas is as below.

 

%INCLUDE '\\XYZ\test2.sas';

%INCLUDE '\\XYZ\test3.sas';

%INCLUDE '\\XYZ\test4.sas';

 

Reeza
Super User

Use PROC PRINTTO before each %include to create and direct the log file to where you want it. 

Astounding
PROC Star

Reeza and I are thinking alike.  I would write a macro:

 

%macro run_one (path);

   proc printto log="&path.log";

   run;

   %include "&path.sas";

   run;

%mend run_one;

 

Then the trick is to call the macro properly:

 

%run_one (\\XYZ\test2.)

%run_one (\\XYZ\test3.)

 

Notice that the dot is part of the macro call, but not the extension of "sas".  That makes it easier for the macro to specify both the log and the program.

KBACHU
Fluorite | Level 6

Thanks Everyone. I tried using proc printto but it still writes the actual output in the original program log file. The log files for test2 and test3 has only the below information.

 

2 The SAS System Wednesday, June 29, 2016 03:48:46 PM

NOTE: PROCEDURE PRINTTO used (Total process time):

real time 0.01 seconds

cpu time 0.00 seconds

 

 

NOTE: PROCEDURE CONTENTS used (Total process time):

real time 0.03 seconds

cpu time 0.03 seconds

 

45

46 %run_one (T:\test2.)

 

 

Astounding
PROC Star

Yes, it absolutely does that.  If you want the output as well as the logs to be moved, you need to add to the macro:

 

%macro run_one (path);

   proc printto log="&path.log";

   run;

   proc printto print="&path.lst";

   run;

   %include "&path.sas";

   run;

%mend run_one;

KBACHU
Fluorite | Level 6

I was wrong. It did work. Thanks everyone for the help.

Reeza
Super User

@KBACHU Please mark the question Solved.

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
  • 25430 views
  • 5 likes
  • 4 in conversation