The chisquare statistic is requested from the SAS Survey Procedures procedure proc surveyfreq. The summary table below provides an example of how to code for a chisquare test in SAS.
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.
Statements  Explanation 

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 nonresponse. 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 crosstabulations 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 chisquare (wchisq), and Wald log linear chisquare (wllchisq), and suppress the standard deviation (nostd) and weighted sums (nowt). Use the chisq option to obtain the RaoScott chisquare and the chisq1 to obtain the RaoScott modified chisquare. 
format riagendr
sexfmt. bpacsz
csz2fmt. ; ; 
Use the format statement to read the SAS formats. 
For complex survey data such as NHANES, we recommend using the RaoScott F adjusted chisquare statistic since it yields a more conservative interpretation than the Wald chisquare.