Hi: Most of the time the "ANY" informats work, ANYDTDTM, for example. Look at the list here: http://go.documentation.sas.com/?docsetId=allprodslang&docsetTarget=syntaxByType-informat.htm&docsetVersion=9.4&locale=en the "ANY" informats are at the top of the page and when you click on a format name, there is usually an example that shows which types of dates you can use with the informat. For me, the ANYDTDTM usually works OK either in an INPUT statement or an INPUT function, as long as my date in the data matches one of their examples. cynthia
For example, this worked for me using an INPUT function with ANYDTDTM -- and for TEST2, it also worked in an INPUT statement:
data testinformat;
length example $1 datestr $21;
infile datalines dlm=',';
input example $ datestr $;
dateinfo = input(datestr,anydtdtm.);
format dateinfo datetime21.;
return;
datalines;
a,07-Apr-2015 11:32 PM
b,07APR2015
d,07APR2015:23:32:08
d,04072015
e,04/07/15
f,04-15
g,APR2015
h,20150407
i,April 7 2015
;
run;
proc print data=testinformat;
run; data test2; length example $1 ; infile datalines dlm=','; input example $ dateinfo : anydtdtm.; format dateinfo datetime21.; return; datalines; a,07-Apr-2015 11:32 PM b,07APR2015 d,07APR2015:23:32:08 d,04072015 e,04/07/15 f,04-15 g,APR2015 h,20150407 i,April 7 2015 ; run; proc print data=test2; run;
... View more