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

Hi,

I want to create macro for processing date with time something like 

%let processdt = %sysfunc(today(), datetimeformat);

 

 

%put &processdt;

 

the output should be 2019-08-01 00:00:00.0

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User
proc format;
picture dtStamp (round) 
low - high = '%Y-%0m-%0d %0H:%0M:%0S.%s' (datatype=datetime);
run;

%put NOTE: %sysfunc(datetime(), dtStamp.);

Here's the roll your own format options, dtStamp is the format name.

 


@meckarthik wrote:

Hi,

I want to create macro for processing date with time something like 

%let processdt = %sysfunc(today(), datetimeformat);

 

 

%put &processdt;

 

the output should be 2019-08-01 00:00:00.0


 

View solution in original post

5 REPLIES 5
PeterClemmensen
Tourmaline | Level 20
data _null_;  
    dt=dhms(today(),0,0,0);;
    put dt= datetime18.;
run;
data_null__
Jade | Level 19

@meckarthik wrote:

Hi,

I want to create macro for processing date with time something like 

%let processdt = %sysfunc(today(), datetimeformat);

 

 

%put &processdt;

 

the output should be 2019-08-01 00:00:00.0


 

 

9    %put NOTE: %sysfunc(datetime(),E8601LX20);
NOTE:  2019-08-01T08:53:14

19   %put NOTE: %sysfunc(datetime(),E8601LX22.1);
NOTE:  2019-08-01T08:56:22.2

Pretty close I think you need the T.  

 

novinosrin
Tourmaline | Level 20

data _null_;
processdt =datetime()-time();
/* write your call symputx here and store in global symbol table*/
put processdt=;
format processdt e8601dt25.;
run;
Reeza
Super User
proc format;
picture dtStamp (round) 
low - high = '%Y-%0m-%0d %0H:%0M:%0S.%s' (datatype=datetime);
run;

%put NOTE: %sysfunc(datetime(), dtStamp.);

Here's the roll your own format options, dtStamp is the format name.

 


@meckarthik wrote:

Hi,

I want to create macro for processing date with time something like 

%let processdt = %sysfunc(today(), datetimeformat);

 

 

%put &processdt;

 

the output should be 2019-08-01 00:00:00.0


 

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 5 replies
  • 1287 views
  • 3 likes
  • 6 in conversation