Reputation: 21
I am having trouble reading a text file which contains a date field with the format "yyyy-mm-dd hh:mm:ss.sss". I wasn't sure if there was an informat that had the same format so I was looking into creating my own with proc format. The following is what I wrote:
proc format;
picture mydate (default=23)
other = '%0Y-%0m-%0d %0H:%0M:%0S';
run;
However, this did not work, and I suspect that it's because the number of seconds has 3 values after the decimal point. My question is, is there an informat the can read this format, or is there a date directive for seconds that can read decimal values?
Thank you!
Upvotes: 2
Views: 2483
Reputation: 4554
You are almost there,just a little change.
proc format;
picture mydate
other = '%0Y-%0m-%0d %0H:%0M:%0s'(datatype=datetime );
run;
data _null_;
date='2015-08-20 17:25:23.562';
_date=input(_in, ANYDTDTM32.);
format _date mydate23.3;
put _all_;
run;
Upvotes: 0
Reputation: 906
Not sure if there is an exact 'format', but for 'informat', you don't have to reinvent the wheel:
data _null_;
_in='2015-08-20 17:25:23.562';
_out=input(_in, ANYDTDTM32.);
put _in= _out= e8601dt25.3;
run;
Upvotes: 2