PROC FREQ can be used to count frequencies of both character and numeric
variables, in one-way, two-way, and three-way tables. In addition, you can use PROC FREQ to create output data sets containing counts and percentages. Finally, if you are statistically inclined, you can use this procedure to compute various statistics such as chi-square, odds ratio, and relative risk.
#Problem:
Using the SAS data set Blood, we will generate one-way frequencies for the variables Gender, BloodType, and AgeGroup.
#Dataset:
Used in the previous example.
#Solution:
title "One-way Frequencies from BLOOD Data Set"; proc freq data=A15028.A28_blood; tables Gender BloodType AgeGroup / nocum nopercent; run;
#Output:
#Explanation:
Here using the Proc freq procedure we can computes counts for each unique value of a variable. Here the TABLES statement to list the variables for which you want to compute
frequencies. Thus, in this example we are trying to calculate the frequencies for the variables Gender, Blood type and Age group. Secondly, w have used some option like NOCUM and NOPERCENT which tells PROC FREQ not to include the two cumulative statistics columns and percentages in the output, respectively.
The above example is single way frequency table and we can also produce two way or three way frequency tables. The below example shows how to produce three way frequency table. By using the college dataset we can build a three way freq table.
proc freq data=A15028.A28_college; tables Gender*Scholarship*SchoolSize; run;
In the above program we try to get a freq table for Gender, Scholarship and School size. To built a multi way freq table we have to use (*) symbol between the variables. The output for the above program will looks like below.
#Output:
From the output, we got Gender wise 2 tables and each table shows whether they have scholarship or not and it is further classified based on the school type. Thus we can easily get the table format which will help us to classify based on the information we needed.
No comments:
Post a Comment