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

hello,

 

I am trying to put data in a new format and i keep on getting an error/warning message saying that the format cannot be found

 

this is my data year looking like 

Cooksam13_1-1650406458252.png

Cooksam13_2-1650406537192.png

this is what proc contents shows me 

 

36263539

DobChar10$EAR.  
bmdobNum8MMDDYY10. bmdob
hepbdateChar10$10.$10.hepbdate
hpdateChar10$EAR.  

 

and then I am trying to convert it to show just a year using this code

data work.vitaldob;
set new.step2;
Dob=put(bcdob,MMDDYYS10. ) ;
Format dob year. ;
hpdate=put(hepbdate,MMDDYYs10.);
format hpdate year.;

run;

but I keep on getting this error

 

 

72 Format dob year. ;
_____
484
NOTE 484-185: Format $YEAR was not found or could not be loaded.
 
73 hpdate=put(hepbdate,MMDDYYs10.);
__________
484
NOTE 484-185: Format $MMDDYYS was not found or could not be loaded.
 
74 format hpdate year.;
_____
484
NOTE 484-185: Format $YEAR was not found or could not be loaded.

please help

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

Updated answer. Looks like BCBOB is the label for BMBOB which is very confusing. 

 

data work.vitaldob;
set new.step2;

Dob=bmdob ;
Format dob year. ;

hpdate=input(hepbdate,yymmdd10.);
format hpdate year.;

run;

View solution in original post

12 REPLIES 12
Reeza
Super User
data work.vitaldob;
set new.step2;

Dob=bcdob ;
Format dob year. ;

hpdate=input(hepbdate,yymmdd10.);
format hpdate year.;

run;

@Cooksam13 wrote:

hello,

 

I am trying to put data in a new format and i keep on getting an error/warning message saying that the format cannot be found

 

this is my data year looking like 

Cooksam13_1-1650406458252.png

Cooksam13_2-1650406537192.png

this is what proc contents shows me 

 

36263539

Dob Char 10 $EAR.    
bmdob Num 8 MMDDYY10.   bmdob
hepbdate Char 10 $10. $10. hepbdate
hpdate Char 10 $EAR.    

 

and then I am trying to convert it to show just a year using this code

data work.vitaldob;
set new.step2;
Dob=put(bcdob,MMDDYYS10. ) ;
Format dob year. ;
hpdate=put(hepbdate,MMDDYYs10.);
format hpdate year.;

run;

but I keep on getting this error

 

 

72 Format dob year. ;
_____
484
NOTE 484-185: Format $YEAR was not found or could not be loaded.
 
73 hpdate=put(hepbdate,MMDDYYs10.);
__________
484
NOTE 484-185: Format $MMDDYYS was not found or could not be loaded.
 
74 format hpdate year.;
_____
484
NOTE 484-185: Format $YEAR was not found or could not be loaded.

please help


 

Cooksam13
Fluorite | Level 6

thanks for this but I still get the same error/warning

 

 

69 data work.vitaldob;
70 set new.step2;
71
72 Dob=bcdob ;
73 Format dob year. ;
_____
484
NOTE 484-185: Format $YEAR was not found or could not be loaded.
 
74
75 hpdate=input(hepbdate,yymmdd10.);
76 format hpdate year.;
77
78 run;
 
NOTE: Numeric values have been converted to character values at the places given by: (Line):(Column).
72:5
PaigeMiller
Diamond | Level 26

You have a varaible BCDOB, but you don't show that variable in PROC CONTENTS. I assume it must be character, is it, according to PROC CONTENTS?

--
Paige Miller
Cooksam13
Fluorite | Level 6

sorry for this mix up

24

bcdobNum8MMDDYY10. bcdob
tarheel13
Rhodochrosite | Level 12

why not just use year function? year=year(bcdob). that extracts the year from a SAS date. 

Cooksam13
Fluorite | Level 6
That works for the bcdob but not for hpdate
get this error for the hpdate

NOTE: Character values have been converted to numeric values at the places given by: (Line):(Column).
73:13
NOTE: Format $MDDYYS was not found or could not be loaded.
NOTE: Invalid numeric data, hepbdate='2010/01/02' , at line 73 column 13.
ID_Person=2010000139 CD_PersonStatus= CD_Gender= AM_FamilySize= DT_Birt
PaigeMiller
Diamond | Level 26

You are getting these errors because some variables are character. THere are no date or time formats for character variables, and you cannot use date or time functions on character variables. This is why I want to see the ENTIRE output from PROC CONTENTS.

--
Paige Miller
PaigeMiller
Diamond | Level 26

Okay, show us the ENTIRE output from PROC CONTENTS. Do not select parts to show us and not show us other parts. Make sure you show us the stuff at the top which indicates the name of the data set that you are running PROC CONTENTS on.

--
Paige Miller
Cooksam13
Fluorite | Level 6
proc contents data = work.vitaldob;
run; quit;

# Variable Type Len Format Informat Label36243539

DobChar10$MDDYYS10.  
bcdobNum8MMDDYY10. bcdob
hepbdateChar10$10.$10.hepbdate
hpdateNum8   

 

Cooksam13_0-1650410404036.png

 

I can only show this information for security reasons 

Tom
Super User Tom
Super User

You already have a DOB variable that is CHAR.  So you cannot make a new one that is numeric.

Either make a NEW variable.

new_dob = year(bcdob);

Or if you are ok with a character DOB variable use PUT() to convert the date in BCDOB into a four digit string with the year value.  And remove that attempt to attach the numeric format to DOB.  There is no need to attach a format to a character variable. SAS already know how to display character string just fine without any special instructions.

dob = put(bcdob,year4.);
format dob;

 

I suspect that in your attempts at various solutions you have overwritten your input.

Try going back to the original data and starting over.

Reeza
Super User

Updated answer. Looks like BCBOB is the label for BMBOB which is very confusing. 

 

data work.vitaldob;
set new.step2;

Dob=bmdob ;
Format dob year. ;

hpdate=input(hepbdate,yymmdd10.);
format hpdate year.;

run;
ChrisNZ
Tourmaline | Level 20

Bottom line: This message appears when you try to apply the year. format to a character variable. It can only be used for a numeric variable. Check your data.

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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
  • 12 replies
  • 1338 views
  • 0 likes
  • 6 in conversation