Is there a way that we can convert the datetime value 20MAY19:09:11:54 to like this 20.05.2019 09:11?
I'm not finding any SAS datetime format which format like 20.05.2019 09:11.
Sorry, I mistyped, the format should be defined as
proc format;
picture dtfmt (default=16)
low - high = '%0d.%0m.%Y %0H:%0M' (datatype=datetime)
;
run;
How about
data test;
datetime='20may2019 09:11:54'dt;
format datetime datetime14.;
run;
Alternatively, you could just roll out your own format
proc format;
picture dtfmt (default=16)
low - high = '0%d.0%m.%Y 0%H:0%M' (datatype=datetime)
;
run;
data test;
datetime='20may2019 09:11:54'dt;
format datetime dtfmt.;
run;
Use the Input Function and the Anydtdtm18. Informat like this
proc format;
picture dtfmt (default=16)
low - high = '0%d.0%m.%Y 0%H:0%M' (datatype=datetime)
;
run;
data test;
datetime='20may2019 09:11:54';
numdt=input(datetime, anydtdtm18.);
format numdt dtfmt.;
run;
Format which you provided is OK to some extend but I'm not seeing the right value in hh:mm. Value which I got in the Output is 09.09.2019 010:0 instead of 09.09.2019 10:50.
Please see the log below
1889 proc format;
1890 picture dtfmt (default=16)
1891 low - high = '0%d.0%m.%Y 0%H:0%M' (datatype=datetime)
1892 ;
NOTE: Format DTFMT is already on the library WORK.FORMATS.
NOTE: Format DTFMT has been output.
1893 run;
NOTE: PROCEDURE FORMAT used (Total process time):
real time 0.00 seconds
cpu time 0.00 seconds
1894 data metadata;
1895 %let etls_stepStartTime = %sysfunc(datetime(), datetime17.);
1896 %put %str(NOTE: &etls_stepStartTime.);
NOTE: 09SEP19:10:50:17
1897 SCHDLD_OBJ_RUN_STRT_TMST=%sysfunc(inputn("&etls_stepStartTime",datetime17.));
1898 format SCHDLD_OBJ_RUN_STRT_TMST dtfmt.;;
1899 run;
Sorry, I mistyped, the format should be defined as
proc format;
picture dtfmt (default=16)
low - high = '%0d.%0m.%Y %0H:%0M' (datatype=datetime)
;
run;
Thank you! it works for me 😛
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.