Please help me out inth following scenario.
How to give informat for the below dates?
02-04-2017T22:12:35
02-10-2017T10:15:00
02-10-2017T10:15
There may be a more direct route, but the following should work:
data have;
infile cards truncover;
input @;
_infile_=catx(':',substr(_infile_,1,10),substr(_infile_,12));
input dt anydtdtm.;
format dt datetime19.;
cards;
02-04-2017T22:12:35
02-10-2017T10:15:00
02-10-2017T10:15
;
Art, CEO, AnalystFinder.com
I think you need to manipulate that to read it directly.
If you had the date part in the year,month,day order then you could use the B8601DT informat.
If you convert the T to a : then the ANYDTDTM informat could make a guess at what date to use.
If you know whether those dates are both in February or if one is in April and the other in October then you could read it in pieces using the appropriate informat. Or you could let SAS guess as to which informat to use by using the ANYDTDTE informat.
data have ;
input @1 str $19.
@1 dt1 anydtdtm19.
@1 d1 mmddyy10. +1 time time8.
@1 d2 ddmmyy10.
@1 d3 anydtdte10.
;
dt2 = input(translate(str,':','T'),anydtdtm19.);
format dt1 dt2 e8601dt. d1 d2 d3 e8601da. time time8. ;
cards;
02-04-2017T22:12:35
02-10-2017T10:15:00
02-10-2017T10:15
;
proc print; run;
Available on demand!
Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.
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.