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.?
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.".
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.".
Perfect, thank you!
Available on demand!
Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.
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.
Select SAS Training centers are offering in-person courses. View upcoming courses for: