BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
advmsj
Obsidian | Level 7

Hi there, when converting dates imported from excel to date9. I am receiving the wrong dates. When reviewing the proc contents, I noticed the format and informat of my imported variable is $10. Does anyone have a suggestion on how I can properly convert the dates to date9.?

1 ACCEPTED SOLUTION

Accepted Solutions
Kurt_Bremser
Super User

So you have certain values in your date column that are neither dates nor missing (empty), which causes PROC IMPORT to import that as character. Either fix the values in the spreadsheet, or run a correcting data step on the imported dataset:

data import2 (drop=_date);
set import (rename=(date=_date));
date = input(_date, informat.);
format date date9.;
run;

Insert the fitting informat in place of "informat.".

View solution in original post

2 REPLIES 2
Kurt_Bremser
Super User

So you have certain values in your date column that are neither dates nor missing (empty), which causes PROC IMPORT to import that as character. Either fix the values in the spreadsheet, or run a correcting data step on the imported dataset:

data import2 (drop=_date);
set import (rename=(date=_date));
date = input(_date, informat.);
format date date9.;
run;

Insert the fitting informat in place of "informat.".

advmsj
Obsidian | Level 7

Perfect, thank you!

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of 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
  • 951 views
  • 1 like
  • 2 in conversation