I am trying to convert date values that are currently stored in character format to numeric with a date format, but no matter how I try to code it I get an error saying: ERROR 48-59: The format XXXXX was not found or could not be loaded.
I have tried using it in a data step with a format statement:
data new; set old;
format datevar mmddyy10.;
run;
I have tried using an input statement to convert it to numeric first.
data new; set old;
date2=input(datevar, mmddyy10.);
run;
I have also tried multiple different date formats (date9, mmddyy10, and datetime20). No matter what I do or what date variable I use, I get the message. I'm not trying to use a user-defined date format so I don't know what's going on.
I bet that if you posted from the log that the error is different then you say. I will bet that the actual error is:
NOTE 484-185: Format $MMDDYY was not found or could not be loaded.
Note the $. Your date variable is character so any format associated with a character variable would start with $.
You need to create a numeric date valued variable to apply the format:
You did not state the current appearance of your date variable so I am recommending the informat which will read many character values.
date new;
set old;
NewDatevar= input(datevar,anydtdte32.);
Format newdatevar mmddyy10.;
run;
This is weird. Your formats look like predefined ones. his can happen if the assumption about the datatype is wrong. A reference to a numeric format associated to a charcater variable can get prepended with a $, leading to a not-found message but I wonder if that's the case here.
Can you provide a proc contents and ssome sample records of the input dataset? Also the actual log contents would be helpful.
Worst case you have an issue with your SAS installation. What directories make up your SASHELP library?
A simple test can tell a lot. Please run:
data _null_;
d='21JUL2016'd;
put d= mmddyy10.;
run;
The expected result would be:
d=07/21/2016
Regards.
- Jan.
Ok, forgive me this is going to get a little long because I have several screen shots.
First Jan, I tried your test code and it was successful:
Here are some sample lines of data:
Here are the log contents when I try to run the code a few different ways:
Here is the proc contents:
I bet that if you posted from the log that the error is different then you say. I will bet that the actual error is:
NOTE 484-185: Format $MMDDYY was not found or could not be loaded.
Note the $. Your date variable is character so any format associated with a character variable would start with $.
You need to create a numeric date valued variable to apply the format:
You did not state the current appearance of your date variable so I am recommending the informat which will read many character values.
date new;
set old;
NewDatevar= input(datevar,anydtdte32.);
Format newdatevar mmddyy10.;
run;
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.
Ready to level-up your skills? Choose your own adventure.