DATA Step, Macro, Functions and more

extract date iso 8601 format

Accepted Solution Solved
Reply
Frequent Contributor
Posts: 100
Accepted Solution

extract date iso 8601 format

what functions can I use to extract 2010-12-28 from '2010-12-28T10:15' string?

What is the syntax to convert it (2010-12-28) to numberic ?

 

Thanks, 


Accepted Solutions
Solution
‎04-27-2017 06:28 AM
Super User
Posts: 11,343

Re: extract date iso 8601 format

If you only want the date portion this should work:

data want;
   str='2010-12-28T10:15';
   date= input(str,yymmdd10.);
   format date yymmdd10.;
run;

Note that anything that is not an actual valid 10 character date in the first 10 characters will generate an error.

 

View solution in original post


All Replies
Solution
‎04-27-2017 06:28 AM
Super User
Posts: 11,343

Re: extract date iso 8601 format

If you only want the date portion this should work:

data want;
   str='2010-12-28T10:15';
   date= input(str,yymmdd10.);
   format date yymmdd10.;
run;

Note that anything that is not an actual valid 10 character date in the first 10 characters will generate an error.

 

☑ This topic is solved.

Need further help from the community? Please ask a new question.

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