## Task 3b: How to Perform Chi-Square Test Using SAS Survey Procedures

In this task, you will use the chi-square test in SAS to determine whether gender and blood pressure cuff size are independent of each other.

### Step 1: Set Up SAS to Perform Chi-Square Test

The chi-square statistic is requested from the SAS Survey Procedures procedure proc surveyfreq.  The summary table below provides an example of how to code for a chi-square test in SAS.

IMPORTANT NOTE

These programs use variable formats listed in the Tutorial Formats page. You may need to format the variables in your dataset the same way to reproduce results presented in the tutorial.

Calculating chi-square Using SAS Survey Procedures proc surveyfreq
Statements Explanation
proc surveyfreq data=analysis_data;

Use the SAS Survey procedure, proc surveyfreq, to examine the relationship between two categorical variables.

strata sdmvstra;

Use the strata statement to specify the strata variable (sdmvstra) and account for design effects of stratification.

cluster sdmvpsu;

Use the cluster statement to specify PSU(sdmvpsu) to account for design effects of clustering.

weight wtmec4yr;

Use the weight statement to account for the unequal probability of sampling and non-response.  In this example, the MEC weight for 4 years of data (wtmec4yr) is used.

table sel*riagendr*bpacsz/col row nostd nowt wchisq wllchisq chisq chisq1;

Use the table statement to specify cross-tabulations for which estimates are requested. In the example, the estimates are for age greater than or equal to 20 (sel) by gender (riagendr) and by blood pressure cuff size (bpacsz). The options after the slash will output the column percent (col), row percent (row), Wald chi-square (wchisq), and Wald log linear chi-square (wllchisq), and suppress the standard deviation (nostd) and weighted sums (nowt). Use the chisq option to obtain the Rao-Scott chi-square and the chisq1 to obtain the Rao-Scott modified chi-square.

format riagendr sexfmt. bpacsz csz2fmt. ;

run ;

Use the format statement to read the SAS formats.

IMPORTANT NOTE

For complex survey data such as NHANES, we recommend using the Rao-Scott F adjusted chi-square statistic since it yields a more conservative interpretation than the Wald chi-square.

### Step 2: Review output

• 9,094 respondents have information on blood pressure cuff size.
• The row percentages indicate that males tend to have a larger cuff size than females.
• Because the F adjusted p-value is less than 0.05, you would reject the null hypothesis that gender and blood pressure cuff size are independent. The probability of obtaining a value of 125.55 or more is approximately zero.