06-07-2017 01:30 PM
The following code for outputing the date in uts format gives the data of Jan 1, 1960 instead of current date.
If keep the format as say date9. I get the correct value.
format current1 b8601dt.;
PROC PRINT data=createdates;
title 'The createdates data set';
var current1 ;
The output is
The createdates data set 13:25 Wednesday, June 7, 2017 1
Can anybody help?
06-07-2017 02:01 PM
The createdates data set 13:58 Wednesday, June 7, 2017 1
I there a way can remove the T and have the values like "20170607135842".
The idea is to have it in YYYYMMDDHHmmSS?
06-07-2017 02:17 PM
you may to have to use proc format with picture statement as shown below
PROC FORMAT; picture dt other='%0Y-%0m-%0d%0H%0M%0S' (datatype=datetime); RUN; DATA createdates; current1= put(datetime(),dt.); RUN;
06-07-2017 10:04 PM - edited 06-07-2017 10:10 PM
I appreciate your time and efforts in replying to me and reminding that datetime is the proper format to use.
My objective was to get date in the format YYYYMMDDHHmmSS.
So the last solution is not what I want.
I had to remove T from the output. So I used this. compress(put(datetime(),b8601dt.),'T');
For comparison I ran your and my solution
picture dt other='%0Y-%0m-%0d%0H%0M%0S' (datatype=datetime);
current1= put(datetime(), dt.);
and got the result as follows
current1 = 2017-06-07215453
There could be many other ways to do ,
I am accepting your earlier post as a solution. It put the ray of light on the solution
Thanks once again.
Need further help from the community? Please ask a new question.