DATA Step, Macro, Functions and more

DATE AND TIME

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 13
Accepted Solution

DATE AND TIME

I have an urgent situation. I am trying to export excel file into current date and current time. 

Will be generating two files each day and final output needs to be like below. 

 

File should be named as such [mmddyyyyhhmmss]_ABC

 

Please help urgently. Thank you.


Accepted Solutions
Solution
‎01-05-2017 04:17 PM
Contributor
Posts: 35

Re: DATE AND TIME

Create a timestamp!

 

proc format;
  picture myfmt low-high = '%Y%0m%0d_%0H%0M%0S' (datatype = datetime) ;
run ;

%let timestamp=%sysfunc(datetime(), myfmt.);

View solution in original post


All Replies
Solution
‎01-05-2017 04:17 PM
Contributor
Posts: 35

Re: DATE AND TIME

Create a timestamp!

 

proc format;
  picture myfmt low-high = '%Y%0m%0d_%0H%0M%0S' (datatype = datetime) ;
run ;

%let timestamp=%sysfunc(datetime(), myfmt.);
Occasional Contributor
Posts: 13

Re: DATE AND TIME

marco variable is created but proc export part is not working 

 


data _null_ ;
format dt mmddyy10. tm time. ;
dt = today() ;
tm = timepart(datetime()) ;
charval = compress(put(dt,mmddyy10.)||put(tm,time.), ":/") ;
call symput("dateval",charval) ;
run;

%put &dateval ;

 

 

proc export data= abc 
outfile='C:\Users\mno\New folder\&dateval..xlsx'
dbms = xlsx replace ; putnames=no;
run;

 

final output is generated with name as "&dateval.xlsx" 

no error in log.

Occasional Contributor
Posts: 13

Re: DATE AND TIME

Thank you. This works in proc export. There was a typo in my datastep. Thank you.

Contributor
Posts: 35

Re: DATE AND TIME

No problem, nice work!
☑ This topic is solved.

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

Discussion stats
  • 4 replies
  • 206 views
  • 1 like
  • 2 in conversation