BookmarkSubscribeRSS Feed
silasskovsbo
Calcite | Level 5

Hello all.. I have a problem.

I have several programs, 'program1', 'program2' etc, which shall be run in row. So first 'program1' and then 'program2' etc. I run my programs in batch mode and I have used the %include-statement to run program2 after program1.

My problem is that I want to save specific logs for each program.

How can I do that?

If the programs are for example:

Program 1:

data temp2;

set temp1;

run;

%include' program2'

Program 2:

data temp3;

set temp2;

run;

I have tried with proc printto and dm-statements but have no luck..

Hope you can help me

// Best, Silas Skovsbo, Aarhus University, Denmark

5 REPLIES 5
Quentin
Super User

Hi,

PROC PRINTTO should be able to do this for you.  What problems did you have with that approach?

Something like:

proc printto log="d:\junk\logA.log" new;
run;

%include "d:\junk\A.sas"/source2;

proc printto log="d:\junk\logB.log" new;
run;

%include "d:\junk\B.sas"/source2;

proc printto;
run;


You need to have /source2 on the %include statement to have it write to the log.  And need NEW on the proc printto otherwise it will keep appending.

HTH,

--Q.

The Boston Area SAS Users Group is hosting free webinars!
Next up: Bart Jablonski and I present 53 (+3) ways to do a table lookup on Wednesday Sep 18.
Register now at https://www.basug.org/events.
silasskovsbo
Calcite | Level 5

Thank you for the fast response.

Using /source2 helped a bit. Now I get the full log. But I do get the full log in one textile, logA.

This does not print two separate log-files for program A and one for program B.

Do you know how to get that? And can you make an exact example of it? Just with the mentioned data-statements above?

Thanks again!

ArtC
Rhodochrosite | Level 12

Are you saying that the PROC PRINTTO did not work for you?  Show us the PRINTTO steps.

ArtC
Rhodochrosite | Level 12

as suggested by @Quentin PRINTTO should do the trick.  You could also submit the jobs individually using the OS scheduler.  Other options include the use of the ALTLOG options and the use of DM statements to redirect the log.

Ron_MacroMaven
Lapis Lazuli | Level 10

in the answers I have seen I do not see the close for the printto

%Macro SaveLog

(program

,path=d:\junk\);

PROC Printto log="&Path\&Program..log"

             new;

run; 

%include "&Path\&Program..sas"/source2; 

PROC Printto;

run;

%mend SaveLog;

%SaveLog(A)

%SaveLog(B)

commentary:

personally I use

filename Project '.';

in my autoexec

and in programs:

%include Project(<program-name>);

can you guess I learned SAS on BigIron?

note that the extension is not needed, unless the prefix of the program name has digits

i.e.:

%include Project(01-inport-csv);

this has to be expanded and surrounded with quotes:

%include Project('01-inport-csv.sas');

Ron Fehd  logs maven

SAS Innovate 2025: Call for Content

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!

Submit your idea!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 5 replies
  • 4124 views
  • 2 likes
  • 4 in conversation