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

What is wrong with this code?

PROC FORMAT;
VALUE IncomeB
1 = 'Do Not Know'
2 = 'Less than $25,000'
3 = '$25,000 - $49,999'
4 = '$50,000 - $74,999'
5 = '$75,000 - $99,999'
6 = '$100,000 - $124,999'
7 = '$125,000 - $149,999'
8 = '$150,000 - $174,999'
9 = '$175,000 - $199,999'
10 = '$200,000 - $224,999'
11 = '$225,000 - $249,999'
12 = '$250,000 - $274,999'
13 = '$275,000 - $299,999'
14 = '$300,000 - $324,999'
15 = '$325,000 - $349,999'
16 = '$350,000 - $374,999'
17 = '$375,000 - $399,999'
18 = '$400,000 or More';
RUN;
DATA All_Data_Total;
SET All_Data_Total;
FORMAT CHILD_INCOME_CD IncomeB.;

 

LOG:


283 PROC FORMAT;
284 VALUE IncomeB
285 1 = 'Do Not Know'
286 2 = 'Less than $25,000'
287 3 = '$25,000 - $49,999'
288 4 = '$50,000 - $74,999'
289 5 = '$75,000 - $99,999'
290 6 = '$100,000 - $124,999'
291 7 = '$125,000 - $149,999'
292 8 = '$150,000 - $174,999'
293 9 = '$175,000 - $199,999'
294 10 = '$200,000 - $224,999'
295 11 = '$225,000 - $249,999'
296 12 = '$250,000 - $274,999'
297 13 = '$275,000 - $299,999'
298 14 = '$300,000 - $324,999'
299 15 = '$325,000 - $349,999'
300 16 = '$350,000 - $374,999'
301 17 = '$375,000 - $399,999'
302 18 = '$400,000 or More';
NOTE: Format INCOMEB is already on the library WORK.FORMATS.
NOTE: Format INCOMEB has been output.
303 RUN;

NOTE: PROCEDURE FORMAT used (Total process time):
real time 0.04 seconds
cpu time 0.00 seconds


304 DATA ADKINS.All_Data_Total;
305 SET ADKINS.All_Data_Total;
306 FORMAT CHILD_INCOME_CD IncomeB.; /* No '$' in format reference */
--------
48
ERROR 48-59: The format $INCOMEB was not found or could not be loaded.

307 RUN;

NOTE: The SAS System stopped processing this step because of errors.

 

1 ACCEPTED SOLUTION

Accepted Solutions
Kathryn_SAS
SAS Employee

This ERROR message means that the variable, CHILD_INCOME_CD, is character. You can confirm with 

proc contents data=adkins.all_data_total;
run;

You either need to create a character format or convert the variable to numeric using the INPUT function.

View solution in original post

3 REPLIES 3
Kathryn_SAS
SAS Employee

This ERROR message means that the variable, CHILD_INCOME_CD, is character. You can confirm with 

proc contents data=adkins.all_data_total;
run;

You either need to create a character format or convert the variable to numeric using the INPUT function.

Newtrix
Fluorite | Level 6

Thanks!

Tom
Super User Tom
Super User

That is SAS's idea of being helpful.  Since you tried to use a NUMERIC format with a CHARACTER variable it automatically assumed you forgot to include the $ in the FORMAT statement.  But then it could not find a similarly named CHARACTER format.  Hence the ERROR message.

 

Either make a character format, which should work fine for your simple 1 to 1 format.

VALUE $IncomeB
'1' = 'Do Not Know'
'2' = 'Less than $25,000'
'3' = '$25,000 - $49,999'
...

Or create a numeric variable from your character variable and attach the format to that variable.

DATA All_Data_Total;
  SET All_Data_Total;
  CHILD_INCOME_NUM = input(CHILD_INCOME_CD,32.);
  FORMAT CHILD_INCOME_NUM IncomeB.;
RUN;

 

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