SAS Programming

DATA Step, Macro, Functions and more
BookmarkSubscribeRSS Feed
Suzy_Cat
Pyrite | Level 9

Hello my helpers 🙂

 

I am using below code to route the log to a daily folder on the server and will use the macro %checklogs to pick up any error message or warnings from there.

* Create the daily folder on server;
%let loc=/../../&sysdate.;
x mkdir -p "&loc./";

proc printto log="&loc./daily_extract.log" NEW; run;
...

* Reset log;
proc printto; run;

Current issue I have: 

1) the log is wrapped after everything been done, and will take quite a long time afterwards in order to write the log to the destination.

The user would have received the email notification that the programs have been completed, all the output results all properly generated in the physical location as required (PC location), and they would not notice that the program is still running at the back end and write to the log file since. 

The user will then close SAS EG.

 

Below error message will be showing if someone else from the team runs the macro %checklogs of which will check all log files in the daily folder:

ERROR: File is in use, /../../log/09DEC20/daily_extract.log.

To address this issue,

1) I am going to reduce the log size by using options to control what info to be write to the log files so the time needed for wrapping the log files will be shortened. Any other suggestion regarding to use options?

Options nosource nomprint;

2) I would also like to get the log file write to the destination incrementally so the log file will be finished not long after the email notification. - Any ideas on how this can be achieved?

 

The %checklogs refer to:

https://support.sas.com/resources/papers/proceedings17/1173-2017.pdf

(trouble shooting also in my previous post)

 

Thanks in advance!

 

5 REPLIES 5
ChrisNZ
Tourmaline | Level 20

I don't see why the log should take so long to close. It written in short bursts once the log buffer is full.

Try adding this line to the config file:

 

-LOGPARM "WRITE=IMMEDIATE"

Also, shame on SAS for removing the very useful UNBUFLOG option.

Suzy_Cat
Pyrite | Level 9
Hi Chris,

Thank you so much for the advice.
It is quite a large program which includes lots of macros and programs to run.
it takes at least another 15 mins + (don't know how long exactly) to write the log file to the server after the program finished.

I will test the WRITE=IMMEDIATE and hope it works.
ChrisNZ
Tourmaline | Level 20

> it takes at least another 15 mins + (don't know how long exactly) to write the log file to the server after the program finished.

I can't think of any reason this should ever happen.

This looks like a Tech Support issue, if you don't find a workaround.

 

Kurt_Bremser
Super User

Just a hint, born out of experience:

do not use &sysdate for a path. Use a properly formatted date instead:

%let loc=/../../%sysfunc(today(),yymmdd10.);

This will sort nicely and enable you to access a group of directories easy with simple wildcards (like 2020-10* for October)

Suzy_Cat
Pyrite | Level 9

Hi Kurt,

Awesome advice. That definitely improves the compatibility dealing with variations.

Thanks a log 🙂

sas-innovate-white.png

Our biggest data and AI event of the year.

Don’t miss the livestream kicking off May 7. It’s free. It’s easy. And it’s the best seat in the house.

Join us virtually with our complimentary SAS Innovate Digital Pass. Watch live or on-demand in multiple languages, with translations available to help you get the most out of every session.

 

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 5 replies
  • 1298 views
  • 4 likes
  • 3 in conversation