BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
Wolverine
Pyrite | Level 9

I'm using the following code to save the log after running my program.  The problem is that, if the log file already exists from a previous run, a dialog box pops up and asked if I want to Replace, Append, or Cancel.  I want it to replace by default.  This code runs without error, but the 'replace' command doesn't seem to do anything.

 

dm log 'file "P:\logs\ReportPrint..log"' replace;run;

Also, I know that I can use proc printto to save the log, but I prefer the dm statement so I can watch the log update in SAS as it runs.

1 ACCEPTED SOLUTION

Accepted Solutions
Quentin
Super User

My code looks like:

 dm "log; file ""%sysfunc(pathname(work))/__mylog.log"" replace;";

So I quote the command, and there is a semicolon to separate the log command from the file command, and I also quote the path.  So based on that, you could try:

dm 'log; file "P:\logs\ReportPrint.log" replace;' ;

It usually takes me some tinkering with the quotes etc, but should be doable. 

The Boston Area SAS Users Group (BASUG) is hosting our in person SAS Blowout on Oct 18!
This full-day event in Cambridge, Mass features four presenters from SAS, presenting on a range of SAS 9 programming topics. Pre-registration by Oct 15 is required.
Full details and registration info at https://www.basug.org/events.

View solution in original post

3 REPLIES 3
Reeza
Super User
May not be a valid solution if running interactively, but ALTLOG is also a useful option to be aware of.
Quentin
Super User

My code looks like:

 dm "log; file ""%sysfunc(pathname(work))/__mylog.log"" replace;";

So I quote the command, and there is a semicolon to separate the log command from the file command, and I also quote the path.  So based on that, you could try:

dm 'log; file "P:\logs\ReportPrint.log" replace;' ;

It usually takes me some tinkering with the quotes etc, but should be doable. 

The Boston Area SAS Users Group (BASUG) is hosting our in person SAS Blowout on Oct 18!
This full-day event in Cambridge, Mass features four presenters from SAS, presenting on a range of SAS 9 programming topics. Pre-registration by Oct 15 is required.
Full details and registration info at https://www.basug.org/events.

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!

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
  • 3 replies
  • 1213 views
  • 2 likes
  • 3 in conversation