BookmarkSubscribeRSS Feed
Divya12
Calcite | Level 5

Hi,

 

Please help me to convert Char format $30. to Date9. format in SAS.

 

Date - 2017-10-24

New Date - 24OCT2017.

 

I tried the below code 
format New Date date9.;
New Date= input(date,MMDDYY10.);

 

But I get blank values in the column.

Thanks

2 REPLIES 2
ballardw
Super User

Look closely at the value of "date" such as 2017-10-14. Does that start with a Month? The MMDDYY informat is Month, day, year order.

You would use YYMMDD10. instead of MMDDYY10.

 

Bad idea to place spaces in the middle of variable names too.

 

NewDate= input(date,MMDDYY10.);

format newdate date9.;

Though one wonders why "date" is supposedly Char 30 if it only has 10 characters...

novinosrin
Tourmaline | Level 20
Date='2017-10-24';
NewDate= input(date,yymmdd10.);
format 	NewDate date9.;
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
  • 2 replies
  • 1007 views
  • 0 likes
  • 3 in conversation