DATA Step, Macro, Functions and more

How can the text input date of format 2011-01-01 be converted to a mmddyy10. format?

Accepted Solution Solved
Reply
New Contributor
Posts: 2
Accepted Solution

How can the text input date of format 2011-01-01 be converted to a mmddyy10. format?

How can the text input date of format 2011-01-01 be converted to a mmddyy10. format?


Accepted Solutions
Solution
‎04-18-2012 03:06 PM
Respected Advisor
Posts: 3,156

Re: How can the text input date of format 2011-01-01 be converted to a mmddyy10. format?

Posted in reply to SasNewBieEight

I am not 100% what you need, so maybe you find this helpful:

data _null_;

a='2011-01-01';

b=input(a,yymmdd10.);

format b mmddyy10.;

put 'new format=' b;

run;

Haikuo

View solution in original post


All Replies
Solution
‎04-18-2012 03:06 PM
Respected Advisor
Posts: 3,156

Re: How can the text input date of format 2011-01-01 be converted to a mmddyy10. format?

Posted in reply to SasNewBieEight

I am not 100% what you need, so maybe you find this helpful:

data _null_;

a='2011-01-01';

b=input(a,yymmdd10.);

format b mmddyy10.;

put 'new format=' b;

run;

Haikuo

New Contributor
Posts: 2

Re: How can the text input date of format 2011-01-01 be converted to a mmddyy10. format?

Hi Haikuo,

This is exactly what I needed... I could swear I have tried this, but kept receiving the "Invalid argument to function INPUT" error message.

data begin;

  input date $25.;

  cards;

2011-01-01

2011-01-02

;

run;

data test (drop=date);

set begin;

date2=input(date,yymmdd10.);

format date2 mmddyy10.;

put 'new format=' date2;

run;

LOG:

new format=01/01/2011

new format=01/02/201

Thanks!

🔒 This topic is solved and locked.

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

Discussion stats
  • 2 replies
  • 620 views
  • 1 like
  • 2 in conversation