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

sas-innovate-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!

Register now

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
  • 1036 views
  • 0 likes
  • 3 in conversation