DATA Step, Macro, Functions and more

format date

Accepted Solution Solved
Reply
Contributor
Posts: 62
Accepted Solution

format date

hi,

I have a character date variable  11292000  wich I would like to convert into 20001129.

I used:

data want ;

set have ;

newdate=input (olddate, yymmdd8. );  but the code does not work.

any ideas? thanks

 

 


Accepted Solutions
Solution
‎11-21-2016 11:31 AM
Super User
Posts: 10,538

Re: format date

Of course that wouldn't work. You were telling SAS to read the value 1129 as the year.

data want ;
   set have ;
   newdate=input (olddate, mmddyy8. );  
   FORMAT newdate yymmdd8.;
run;

You may get warnings about conversion of numeric to character if your olddate variable is numeric as INPUT expects character values.

 

View solution in original post


All Replies
Solution
‎11-21-2016 11:31 AM
Super User
Posts: 10,538

Re: format date

Of course that wouldn't work. You were telling SAS to read the value 1129 as the year.

data want ;
   set have ;
   newdate=input (olddate, mmddyy8. );  
   FORMAT newdate yymmdd8.;
run;

You may get warnings about conversion of numeric to character if your olddate variable is numeric as INPUT expects character values.

 

Contributor
Posts: 62

Re: format date

oh I see.

Never mind I fixed it. Thanks

Super User
Posts: 17,912

Re: format date

@archibald Please mark the question as solved.

☑ This topic is solved.

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

Discussion stats
  • 3 replies
  • 290 views
  • 0 likes
  • 3 in conversation