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

## Changing the display of Proc Freq

So I am trying to do a proc freq for data that looks like this

id_num   race

xxx            1

xxx            2

xxx            3

xxx            4

So when I do proc freq on race I want to the display to show actual races instead of 1,2,3,4 like white, black, asian, hispanic.

I have tried a few things (replacing values but that didn't work at all) but can't get anything close so all I really have is.

proc freq data=test;

tables race;

title;

footnote;

run;

which brings up

Race Code RACE Frequency Percent Cumulative
Frequency Cumulative
Percent
 0 3772 0.98 3772 0.98 1 185936 48.20 189708 49.18 2 139248 36.10 328956 85.28 3 9606 2.49 338562 87.77 4 13978 3.62 352540 91.39 5 27078 7.02 379618 98.41 6 6127 1.59 385745 100.00 Frequency Missing = 16

but I

1 ACCEPTED SOLUTION

Accepted Solutions
Super User

## Re: Changing the display of Proc Freq

What you are looking for is a format.

You define the values with proc format:

Proc format;

value race

1='White'

2='Black'

3='Native American'

/* continue as needed*/

;

run;

Use by

proc freq data=test;

tables race;

format race race.;

run;

Note: the FORMAT reference ends in a period to tell SAS that it is a format not a variable.

2 REPLIES 2
Super User

## Re: Changing the display of Proc Freq

What you are looking for is a format.

You define the values with proc format:

Proc format;

value race

1='White'

2='Black'

3='Native American'

/* continue as needed*/

;

run;

Use by

proc freq data=test;

tables race;

format race race.;

run;

Note: the FORMAT reference ends in a period to tell SAS that it is a format not a variable.

Quartz | Level 8

## Re: Changing the display of Proc Freq

Hi,

Using a format should produce the results you want:

/* create the format */

proc format;
value racefmt
1 = 'white'
2 = 'black'
3 = 'asian'
4 = 'hispanic';
run;

/* source data  */

data test;
length id_num \$5 race 8.;
input id_num race;
datalines;
aaa 1
bbb 2
ccc 3
ddd 4
;

/* display using format */

proc freq data = test ;
tables race ;
format race racefmt.;
run;

Discussion stats
• 2 replies
• 834 views
• 0 likes
• 3 in conversation