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

I have a stored process which I run from an excel report.  All the sp does is execute a code module which loads data to a table.  The sp runs fine but I need to save the log and don't know how to get it to output into the excel I execute from or even place a log somewhere on the unix server.  We are running SAS 9.4 on unix.

 

How can I do this?

 

Thanks,

Elliott

1 ACCEPTED SOLUTION

Accepted Solutions
Quentin
Super User

Yes, you can use the macro language to generate a timestamp, like:

%put %sysfunc(today(),yymmddn8);
20170614

%put %sysfunc(datetime(),b8601dt15);
20170614T104305

Use like:

 

 

proc printto new log="/somedir/mylog_%sysfunc(datetime(),b8601dt15).log";
run;

The stored procss server usually has macro variables with name of the stored process, name of the user, etc.  So sometimes I will put those into the name of the log file as well.  I  all the log files for X days, in case someone reports a problem.  Having the name of the stored process and the user in the log file makes it easier to find the appropriate log.

 

 

Note some server admins might not like this approach, because if they have configured STP logs to go to a central location, using PROC PRINTTO to redirect the log prevents the log from being written wherever they expect it.  If ALTLOG could be executed within a session, I would use that instead.

BASUG is hosting free webinars Next up: Mike Sale presenting Data Warehousing with SAS April 10 at noon ET. Register now at the Boston Area SAS Users Group event page: https://www.basug.org/events.

View solution in original post

4 REPLIES 4
Quentin
Super User

You can use PROC PRINTTO at the beginning of your STP to send the log file somewhere.

 

proc printto new log="/somedir/mylog.log";
run;

*main code here;

proc printto; *restore defaults;
run;

 

I haven't done much with calling stored processes from Excel, but I would think if you want to display it in the Excel, there must me some way to steam the contents back to Excel.  Of course not sure I would want to actually SEE a log file viewed in an Excel sheet....

 

If you don't need a permanent log file, you can send it to work dir with log="%sysfunc(pathname(work))/mylog.log".

BASUG is hosting free webinars Next up: Mike Sale presenting Data Warehousing with SAS April 10 at noon ET. Register now at the Boston Area SAS Users Group event page: https://www.basug.org/events.
Elliott
Obsidian | Level 7

Thanks Quentin,  this is what I need.. is there any way to append a date stamp onto the log name when it outputs?

 

Thanks,

Quentin
Super User

Yes, you can use the macro language to generate a timestamp, like:

%put %sysfunc(today(),yymmddn8);
20170614

%put %sysfunc(datetime(),b8601dt15);
20170614T104305

Use like:

 

 

proc printto new log="/somedir/mylog_%sysfunc(datetime(),b8601dt15).log";
run;

The stored procss server usually has macro variables with name of the stored process, name of the user, etc.  So sometimes I will put those into the name of the log file as well.  I  all the log files for X days, in case someone reports a problem.  Having the name of the stored process and the user in the log file makes it easier to find the appropriate log.

 

 

Note some server admins might not like this approach, because if they have configured STP logs to go to a central location, using PROC PRINTTO to redirect the log prevents the log from being written wherever they expect it.  If ALTLOG could be executed within a session, I would use that instead.

BASUG is hosting free webinars Next up: Mike Sale presenting Data Warehousing with SAS April 10 at noon ET. Register now at the Boston Area SAS Users Group event page: https://www.basug.org/events.

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