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.

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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