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

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.

 

1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

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;

 

View solution in original post

3 REPLIES 3
jklaverstijn
Rhodochrosite | Level 12

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.

csanfor2
Fluorite | Level 6

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:

test.png

 

Here are some sample lines of data:

sample data.png

 

Here are the log contents when I try to run the code a few different ways:

attempt1.png

 

 

Attempt2.png

 

Here is the proc contents:

contents1.png

contents2.png

ballardw
Super User

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: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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
  • 3 replies
  • 56264 views
  • 3 likes
  • 3 in conversation