0

I have a categorical variable, say SALARY_GROUP, and a group variable, say COUNTRY. I would like to get the relative frequency of SALARY_GROUP within COUNTRY in SAS. Is it possible to get it by proc SUMMARY or proc means?

Giorgio Spedicato
  • 2,413
  • 3
  • 31
  • 45

2 Answers2

0

Perhaps explore proc tabulate and a counter variable?

0

Yes, You can calculate the relative frequency of a categorical variable using both Proc Means and Proc Summary. For both procs you have to:

-Specify NWAY in the proc statement,

-Specify in the Class statement your categorical fields,

-Specify in the Var statement your response or numeric field.

Example below is for proc means:

Dummy Data:

/*Dummy Data*/
data work.have;
input Country $ Salary_Group $ Value;
datalines;
USA Group1 100
USA Group1 100
GBR Group1 100
GBR Group1 100
USA Group2 20
USA Group2 20
GBR Group2 20
GBR Group1 100
;
run;

Code:

*Calculating Frequncy and saving output to table sg_means*/
proc means data=have n nway ;
class Country Salary_Group;
var Value;
output out=sg_means n=frequency;
run;

Output Table:

Country=GBR Salary_Group=Group1 _TYPE_=3 _FREQ_=3 frequency=3 
Country=GBR Salary_Group=Group2 _TYPE_=3 _FREQ_=1 frequency=1 
Country=USA Salary_Group=Group1 _TYPE_=3 _FREQ_=2 frequency=2 
Country=USA Salary_Group=Group2 _TYPE_=3 _FREQ_=2 frequency=2 
momo1644
  • 1,769
  • 9
  • 25