# One Sample Test of Proportions Using SAS: proc freq

Example

libname in 'C:\temp';

**proc format**;

value colicf 1="Yes" 2="No";

**run;**

**data** pbkid;set in.pbkid;

format colic colicf.;

**run;**

**proc freq** data=pbkid;

tables colic / binomial(p=0.07);

**run;**

Notice that the Z statistic = 5.04 although our Z statistic was = 5.24. This is due to rounding.

The setup of the data is important. PROC FREQ will run a binomial test assuming that the probability of interest is the first level of the variable (in sorting order) in the TABLES statement. For example, the above statements run a binomial test on COLIC, which takes one of two numeric values – a 1 (Yes) or a 2 (No). The binomial test is applied to COLIC values of 1 because it is the first sorted value for that variable.

The LEVEL= option in the TABLES statement will modify the group level on which the test of proportions is performed. If the COLIC variable were set up to be 0=No and 1=Yes, a common format for categorical data, the default settings would result in a binomial test on the "No" values because 0 comes before 1 in sorting order. To make PROC FREQ run the binomial test on the "Yes" values of 1, use the LEVEL= option to look not at the first value of COLIC but the second as shown in the next example.

**proc freq** data=pbkid;

tables colic / binomial(p=0.05 level=2);

**run;**

If the variable COLIC were a character variable instead, the binomial test would, by default, consider the level of interest to be the first alphabetically, so if the responses are "no" and "yes," the level of interest would be "no". To have this switched, again use the LEVEL= option, specifying the character string "yes".

**proc freq** data=pbkid;

tables colic / binomial(p=0.05 level="Yes");

**run;**

You should always check the output to make sure you are reporting what you think you are reporting! Here, note the statement:

**Binomial Proportion for colic = Yes**