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

I have a column calls as_of_date which is a character filed and the format is yyyy-mm-dd like 2020-05-01. How do I convert it to numeric?

I tried input(as_of_date, DDMMYY10.) and several of other formats but they did not work.

Thanks.

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
PeterClemmensen
Tourmaline | Level 20
data test;
    dt1 = '2020-05-01';
    dt2 = input(dt1, yymmdd10.);
    format dt2 yymmdd10.;
run;

View solution in original post

3 REPLIES 3
PeterClemmensen
Tourmaline | Level 20
data test;
    dt1 = '2020-05-01';
    dt2 = input(dt1, yymmdd10.);
    format dt2 yymmdd10.;
run;
ballardw
Super User

Hint in reading informat and format descriptions:

YY = year  (2 or 4 digits)

MM = month number

DD = day of month number

 

So when your data is in year month day order it becomes a bit more obvious that you want some form of YYMMDD informat/format.

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
  • 3 replies
  • 40237 views
  • 5 likes
  • 4 in conversation