Converting Character Date to SAS Date

Accepted Solution Solved
Reply
New Contributor
Posts: 4
Accepted Solution

Converting Character Date to SAS Date

I have a date field in my dataset that isn't formatted in any format I've ever had to convert to a date. The character date variable is formatted: "2013-06-28"

data test2;

set test;

pay_date=input(PaymentDate, date9.);

format pay_date date9.;

run;

The error I get is:

NOTE: Invalid argument to function INPUT at line 15 column 11.

What am I doing wrong? Thanks!


Accepted Solutions
Solution
‎09-06-2013 08:39 AM
Respected Advisor
Posts: 3,799

Re: Converting Character Date to SAS Date

Posted in reply to aprilewilson

All Replies
Solution
‎09-06-2013 08:39 AM
Respected Advisor
Posts: 3,799

Re: Converting Character Date to SAS Date

Posted in reply to aprilewilson

YYMMDD10

New Contributor
Posts: 4

Re: Converting Character Date to SAS Date

Posted in reply to data_null__

So obvious but I couldn't get there on my own. Thanks Smiley Happy

Super Contributor
Posts: 543

Re: Converting Character Date to SAS Date

Posted in reply to aprilewilson

Hi.

You could do this:

data test2;

set test;

year = scan("paymentDate",1,"-");

month = scan("paymentDate",2,"-");

day = scan("paymentDate",3,"-");

pay_date = mdy(month,day,year);

format pay_date date9.;

drop month day year;

run;

Anca.

🔒 This topic is solved and locked.

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

Discussion stats
  • 3 replies
  • 568 views
  • 3 likes
  • 3 in conversation