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

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


1 ACCEPTED SOLUTION

Accepted Solutions
Haikuo
Onyx | Level 15

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;

View solution in original post

7 REPLIES 7
Haikuo
Onyx | Level 15

is this what you are after?

data _null_;

     old='15.04.2014 10:15';

     new=input(old,ANYDTDTM23.);

     put new=datetime23.;

run;

danimian
Calcite | Level 5

I need text '15.04.2014 10:15' from old in new as date in format DD.MM.YYY HH:MM

slchen
Lapis Lazuli | Level 10


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;

Haikuo
Onyx | Level 15

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;

danimian
Calcite | Level 5

Yes Smiley Happy Its working fine now. Thanks a lot.

Best Regards


kristi_jencks
Calcite | Level 5

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;

AndrewHowell
Moderator

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;

sas-innovate-white.png

Special offer for SAS Communities members

Save $250 on SAS Innovate and get a free advance copy of the new SAS For Dummies book! Use the code "SASforDummies" to register. Don't miss out, May 6-9, in Orlando, Florida.

 

View the full agenda.

Register now!

How to connect to databases in SAS Viya

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.

Discussion stats
  • 7 replies
  • 2738 views
  • 3 likes
  • 5 in conversation