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.;

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 2 replies
  • 406 views
  • 0 likes
  • 3 in conversation