DATA Step, Macro, Functions and more

How to add current date time in log file name?

Accepted Solution Solved
Reply
Contributor
Posts: 74
Accepted Solution

How to add current date time in log file name?

Hi

 

This is my sample program

proc printto log='/Desktop/alternate-log-file.log';

run;

Data test;

Input ID name $ Amount;

Datalines;

 

1 A 10

2 B 20

3 C 30

4 D 40

5 E 50

;

Run;

proc printto;

run;

 

I want to know how can I add current date and time timestamp in the name "alternate-log-file.log"?

Any suggestion.

 

 

Regards

Sourav


Accepted Solutions
Solution
‎02-14-2018 02:08 AM
Super User
Super User
Posts: 9,840

Re: How to add current date time in log file name?

Posted in reply to Sourav_sas

What type of timestamp, there are various formats. E.g.

proc printto log="/desktop/alternate_log_file_%sysfunc(now(),datetime.).log";

proc printto log="/desktop/alternate_log_file_%sysfunc(date(),date9.).log";

proc printto log="/desktop/alternate_log_file_%sysfunc(date(),e8601dt.).log";

View solution in original post


All Replies
Solution
‎02-14-2018 02:08 AM
Super User
Super User
Posts: 9,840

Re: How to add current date time in log file name?

Posted in reply to Sourav_sas

What type of timestamp, there are various formats. E.g.

proc printto log="/desktop/alternate_log_file_%sysfunc(now(),datetime.).log";

proc printto log="/desktop/alternate_log_file_%sysfunc(date(),date9.).log";

proc printto log="/desktop/alternate_log_file_%sysfunc(date(),e8601dt.).log";
☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 1 reply
  • 305 views
  • 1 like
  • 2 in conversation