Can anyone advise on the appropriate SAS informat to read in a datetime (dd/mm/yyyy hh:mm) ???
eg
data _null_;
informat from_dt datetime????.;
input
SAS might not support the specific datetime format your data is in. You could either try to convert the incoming data to a frendlier format or you could parse the datetime using the substr, DHMS and MDY functions:
data test;
format dtstr $16. dt datetime22.4;
dtstr='01/01/1960 00:00';
day=substr(dtstr,1,2);
month=substr(dtstr,4,2);
year=substr(dtstr,7,4);
hour=substr(dtstr,11,2);
minute=substr(dtstr,15,2);
dt=DHMS(MDY(1*month,1*day,1*year),1*hour,1*minute,0);
output;
run;
Or alternatively you could convert the datetime string into a datetimew.d format and input the formatted string:
data test;
format dtstr $16. dstr $8. tstr $5. indtstr $14. dt datetime22.4;
dtstr='01/01/1960 00:00';
dstr=put(input(substr(dtstr,1,10),mmddyy10.),date8.);
tstr=substr(dtstr,12);
indtstr=dstr!!':'!!tstr;
dt=input(indtstr,datetime14.0);
output;
run;
The conversion can be compressed to a single but complex statement, so creating a macro for this might be a good decision.