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

I have dates of this format: '2018-04-19T06:16' stored as $16 (format) and $200 (informat). I want to create a separate date (date9) and time (time5) from this.

I tried the following code but ended up with "NOTE: Invalid argument to function INPUT". I assume the issue may be the format I am attempting to give it is wrong, but I don't see the format I have listed in https://documentation.sas.com/doc/en/vdmmlcdc/1.0/leforinforref/n0av4h8lmnktm4n1i33et4wyz5yy.htm 

dtm = input(dtc, datetime16.);
dt = datepart(dtm);
tm = timepart(dtm);
1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

That T means you need a quite different informat:

data example;
  x='2018-04-19T06:16';
  dt = input(x,e8601dt.);
  format dt datetime.;
run;

https://documentation.sas.com/doc/en/vdmmlcdc/1.0/leforinforref/p0jd9jaqmxd2ezn1kncmpgfqcpiz.htm

 

Note that the link you used is for FORMATS, to display values, not read them. Just needed to go down the page a bit further but experience is what lets some of us recognize when you need one of the E8601 or B8601 type informats.

View solution in original post

1 REPLY 1
ballardw
Super User

That T means you need a quite different informat:

data example;
  x='2018-04-19T06:16';
  dt = input(x,e8601dt.);
  format dt datetime.;
run;

https://documentation.sas.com/doc/en/vdmmlcdc/1.0/leforinforref/p0jd9jaqmxd2ezn1kncmpgfqcpiz.htm

 

Note that the link you used is for FORMATS, to display values, not read them. Just needed to go down the page a bit further but experience is what lets some of us recognize when you need one of the E8601 or B8601 type informats.

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

Register Now

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 1 reply
  • 1211 views
  • 0 likes
  • 2 in conversation