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.

hackathon24-white-horiz.png

The 2025 SAS Hackathon Kicks Off on June 11!

Watch the live Hackathon Kickoff to get all the essential information about the SAS Hackathon—including how to join, how to participate, and expert tips for success.

YouTube LinkedIn

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