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

Hello,

 

So I created a new variable in my SAS dataset, called raceeth. I did the exact same steps as I had for all the other variables in my dataset, created the format, and then applied the format. However, SAS keeps saying my format was not found/could not be loaded, though there didnt appear to be an error when I created the format. All other formats for the other variables are working correctly, btw.

 

Here is my code:

 

 

data MHS.identification2;

set MHS.identification;

if age < 20 then agegroup = 1;

if age >= 20 and age < 25 then agegroup = 2;

if age >= 25 and age < 30 then agegroup = 3;

if age >= 30 and age < 35 then agegroup = 4;

if age >=35 and age < 40 then agegroup = 5;

if age >=40 then agegroup = 6;

if income < 10000 then incomegroup =1;

if income >=10000 and income <14999 then incomegroup =2;

if income >=15000 and income <19999 then incomegroup =3;

if income >=20000 and income <24999 then incomegroup =4;

if income >=25000 and income <34999 then incomegroup =5;

if income >=35000 and income <49999 then incomegroup =6;

if income >=50000 and income <74999 then incomegroup =7;

else if income >= 75000 then incomegroup=8;

if county='LEX' then county2='Lex';

if county='RICH' then county2='Rich';

if county='SUM' then county2='Sum';

if race='1' and ethnicity='1' then RaceEth='11';

if race='1' and ethnicity='2' then RaceEth='12';

if race='2' and ethnicity='1' then RaceEth='21';

if race='2' and ethnicity='2' then RaceEth='12';

if race='3' and ethnicity='1' then RaceEth='31';

if race='3' and ethnicity='2' then RaceEth='12';

if race='4' and ethnicity='1' then RaceEth='41';

if race='4' and ethnicity='2' then RaceEth='12';

if race='5' and ethnicity='1' then RaceEth='31';

if race='5' and ethnicity='2' then RaceEth='12';

if race='6' and ethnicity='1' then RaceEth='61';

if race='6' and ethnicity='2' then RaceEth='12';

if race='7' and ethnicity='1' then RaceEth='61';

if race='7' and ethnicity='2' then RaceEth='12';

run;

 

*formats;

proc format;

value frace

1 = 'Black'

2 = 'White'

3 = 'Asian'

4 = 'NativeAM'

5 = 'HawaiianPI'

6 = 'Multi'

7 = 'Other'

 

;

value Agegroup

1 = '<20'

2 = '20-24'

3 = '25-29'

4 = '30-34'

5 = '35-39'

6 = '40+'

 

;

value fethnicity

1 = 'Non-Hisp'

2 = 'Hisp'

 

;

value fmarital

1 = 'Single'

2 = 'Separated'

3 = 'Divorced'

4 = 'Widowed'

5 = 'Married'

 

;

value fincomegroup

1 = 'Less than 10000'

2 = 'Between 10000-14999'

3 = 'Between 15000-19999'

4 = 'Between 20000-24999'

5 = 'Between 25000-34999'

6 = 'Between 35000-49999'

7 = 'Between 50000-74999'

8 = '75000 and up'

 

;

value fraceeth

11 = 'Black'

12 = 'Hispanic'

21 = 'White'

31 = 'Asian/PI/Hawaiian'

41 = 'Native American'

61 = 'Multi/Other'

 

;

value feducat

0 = 'None'

1 = 'Less than HS'

2 = 'Less than HS'

3 = 'Less than HS'

4 = 'Less than HS'

5 = 'Less than HS'

6 = 'Less than HS'

7 = 'Less than HS'

8 = 'Less than HS'

9 = 'High School'

10 = 'High School'

11 = 'High School'

12 = 'High School'

13 = 'More than HS'

14 = 'More than HS'

15 = 'More than HS'

16 = 'More than HS'

17 = 'More than HS'

18 = 'More than HS'

22 = 'More than HS'

 

;

run;

 

 

*apply formats;

data mhs.identification2;

set mhs.identification2;

format Race frace. Agegroup Agegroup. Ethnicity fEthnicity. Marital fMarital. Incomegroup fIncomegroup. Educat fEducat. Raceeth fraceeth.;

run;

 

 

FYI, the creation of the variable went fine and shows up when viewing the dataset.

 

Here is the log window after attempting the formats:

 

 

*formats;

53

54 proc format;

55 value frace

56 1 = 'Black'

57 2 = 'White'

58 3 = 'Asian'

59 4 = 'NativeAM'

60 5 = 'HawaiianPI'

61 6 = 'Multi'

62 7 = 'Other'

63 ;

NOTE: Format FRACE has been output.

64 value **bleep**egroup

65 1 = '<20'

66 2 = '20-24'

67 3 = '25-29'

68 4 = '30-34'

69 5 = '35-39'

70 6 = '40+'

71 ;

NOTE: Format **bleep**EGROUP has been output.

72 value fethnicity

73 1 = 'Non-Hisp'

74 2 = 'Hisp'

75 ;

NOTE: Format FETHNICITY has been output.

76 value fmarital

77 1 = 'Single'

78 2 = 'Separated'

79 3 = 'Divorced'

80 4 = 'Widowed'

81 5 = 'Married'

82 ;

NOTE: Format FMARITAL has been output.

83 value fincomegroup

84 1 = 'Less than 10000'

85 2 = 'Between 10000-14999'

86 3 = 'Between 15000-19999'

87 4 = 'Between 20000-24999'

88 5 = 'Between 25000-34999'

89 6 = 'Between 35000-49999'

90 7 = 'Between 50000-74999'

91 8 = '75000 and up'

92 ;

NOTE: Format FINCOMEGROUP has been output.

93 value fraceeth

94 11 = 'Black'

95 12 = 'Hispanic'

96 21 = 'White'

97 31 = 'Asian/PI/Hawaiian'

98 41 = 'Native American'

99 61 = 'Multi/Other'

100 ;

NOTE: Format FRACEETH has been output.

101 value feducat

102 0 = 'None'

103 1 = 'Less than HS'

104 2 = 'Less than HS'

105 3 = 'Less than HS'

106 4 = 'Less than HS'

107 5 = 'Less than HS'

108 6 = 'Less than HS'

109 7 = 'Less than HS'

110 8 = 'Less than HS'

111 9 = 'High School'

112 10 = 'High School'

113 11 = 'High School'

114 12 = 'High School'

115 13 = 'More than HS'

116 14 = 'More than HS'

117 15 = 'More than HS'

118 16 = 'More than HS'

119 17 = 'More than HS'

120 18 = 'More than HS'

121 22 = 'More than HS'

122 ;

NOTE: Format FEDUCAT has been output.

123 run;

NOTE: PROCEDURE FORMAT used (Total process time):

real time 0.07 seconds

cpu time 0.07 seconds

@

124 data mhs.identification2;

125 set mhs.identification2;

126 format Race frace. Agegroup **bleep**egroup. Ethnicity fEthnicity. Marital fMarital. Incomegroup

126! fIncomegroup. Educat fEducat. Raceeth fraceeth.;

---------

48

ERROR 48-59: The format $FRACEETH was not found or could not be loaded.

127 run;

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

WARNING: The data set MHS.IDENTIFICATION2 may be incomplete. When this step was stopped there were 0

observations and 49 variables.

WARNING: Data set MHS.IDENTIFICATION2 was not replaced because this step was stopped.

NOTE: DATA statement used (Total process time):

real time 0.07 seconds

cpu time 0.01 seconds

 

1 ACCEPTED SOLUTION

Accepted Solutions
unison
Lapis Lazuli | Level 10

@SM8 , adjust your format definition in the following way:

 

data have;
	input race $ @@;
	datalines;
1 2 3 4 5 6 7
;
run;

proc format;
	value $frace '1'='Black' '2'='White' '3'='Asian' '4'='NativeAM' 
		'5'='HawaiianPI' '6'='Multi' '7'='Other';
run;

data want;
	set have;
	format race $frace.;
run;

What @Tom pointed out is that your variable 'Race' in your old dataset is character and your format definition 'frace' is numeric. SAS will look at the variable you are trying to format and look for a $fmtname.

 

Does this help?

-unison

View solution in original post

3 REPLIES 3
Tom
Super User Tom
Super User

You defined the numeric format RACE (which converts numbers like 1,2,3) and tried to attach it to a character variable (which has values like '1','2','3').  SAS tries to be helpful and assumes you meant to use the character format $RACE with your character variable.  But you never defined such a format.

 

Either make character formats. Or make numeric variables.

SM8
Obsidian | Level 7 SM8
Obsidian | Level 7

Thank you! Are you referring to the Race format or the RaceEth? I'm still a little confused!

unison
Lapis Lazuli | Level 10

@SM8 , adjust your format definition in the following way:

 

data have;
	input race $ @@;
	datalines;
1 2 3 4 5 6 7
;
run;

proc format;
	value $frace '1'='Black' '2'='White' '3'='Asian' '4'='NativeAM' 
		'5'='HawaiianPI' '6'='Multi' '7'='Other';
run;

data want;
	set have;
	format race $frace.;
run;

What @Tom pointed out is that your variable 'Race' in your old dataset is character and your format definition 'frace' is numeric. SAS will look at the variable you are trying to format and look for a $fmtname.

 

Does this help?

-unison

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 3 replies
  • 1739 views
  • 0 likes
  • 3 in conversation