Hello,
i have a field date_in with data type character with value for example '15.04.2014 10:15' (DD.MM.YYY HH:MM)
Target field date_out has numeric type.
Is there any SAS date format which match with this format?
or how i can deliver the date in above format?
I just tried some formats with input(date_in, format) but cannot find the wanted format result.
Thanks for your support in advance
There is no out-of box format for your requirement, except you have to make your own:
proc format;
picture cus_dtm
low - high = '%0d.%0m.%Y %0h:%0M'
(datatype=datetime);
run;
data _null_;
old='15.04.2014 10:15';
new=input(old,ANYDTDTM23.);
put new=cus_dtm20.;
run;
is this what you are after?
data _null_;
old='15.04.2014 10:15';
new=input(old,ANYDTDTM23.);
put new=datetime23.;
run;
I need text '15.04.2014 10:15' from old in new as date in format DD.MM.YYY HH:MM
PROC FORMAT;
picture dt low-high='%0d.%0m.%0Y %0H:%0M' (datatype=datetime);
RUN;
data _null_;
old='15.04.2014 10:15';
new=input(old,ANYDTDTM23.);
put new=dt.;
run;
There is no out-of box format for your requirement, except you have to make your own:
proc format;
picture cus_dtm
low - high = '%0d.%0m.%Y %0h:%0M'
(datatype=datetime);
run;
data _null_;
old='15.04.2014 10:15';
new=input(old,ANYDTDTM23.);
put new=cus_dtm20.;
run;
Yes Its working fine now. Thanks a lot.
Best Regards
My current character value is stored as DD.MM.YYY HH:MM. when changing it to the numeric value.
data _null_;
old='15.04.2014 10:15';
new=input(old,ANYDTDTM23.);
put new=datetime23.;
run;
One further recommendation:
Store the format somewhere permanently, so it's always available, and you don't have to keep redefining it in each SAS session:
proc format library=corpdata.myfmts;
picture cus_dtm
low - high = '%0d.%0m.%Y %0h:%0M'
(datatype=datetime);
run;
options fmtsearch=(corpdata.myfmts),
data _null_;
old='15.04.2014 10:15';
new=input(old,ANYDTDTM23.);
put new=cus_dtm20.;
run;
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!
Need to connect to databases in SAS Viya? SAS’ David Ghan shows you two methods – via SAS/ACCESS LIBNAME and SAS Data Connector SASLIBS – in this video.
Find more tutorials on the SAS Users YouTube channel.