In this task, you will use the chisquare test in SUDAAN to determine whether calcium supplement use and treatment for osteoporosis are independent of each other for men and women ages 50 years and older.
This example uses the demoadv dataset (download at Sample Code and Datasets).This dataset already contains a variable anycalsup that has a value of 1 for those who report calcium supplement use, and a value of 2 for those who do not. A participant was considered not to have any calcium supplement use if the daily average amount of calcium supplement use was zero; otherwise, a participant was considered a supplement user (see Supplement Code under Sample Code and Module 9, Task 4 for more information). The variable treatosteo indicates treatment for osteoporosis. A participant was coded as having had treatment for osteoporosis if he or she responded “yes” to OSQ.070 (“{Were you/Was SP} treated for osteoporosis?”) from the osteoporosis questionnaire, and was set to “no” if he or she responded “no” to OSQ.070 or to OSQ.060 (“Has a doctor ever told {you/SP} that {you/s/he} had osteoporosis, sometimes called thin or brittle bones?”) from the osteoporosis questionnaire. (The SAS code to create this variable is found in the “Supplement Program” sample SAS code.) The demoadv dataset for this example only includes those with MEC weights (wtmec2yr>0).
The chisquare statistic is requested from the SUDAAN procedure proc crosstab. The summary table below provides an example of how to code for a chisquare test in SUDAAN.
These programs use variable formats listed in the sample program. You may need to format the variables in your dataset the same way to reproduce results presented in the tutorial.
Statements  Explanation 

proc sort data =demoadv; by sdmvstra sdmvpsu; run ; 
Use the SAS procedure, proc sort, to sort the data by strata (sdmvstra) and PSUs(sdmvpsu) before running the crosstab procedure in SUDAAN. 
proc crosstab data=demoadv design=wr; 
Use proc crosstab to examine the relationship between two categorical variables. 
nest sdmvstra sdmvpsu; 
Use the nest statement with strata (sdmvstra) and PSU (sdmvpsu) to account for the design effects. 
weight wtmec2yr; 
Use the weight statement to account for the unequal probability of sampling and nonresponse. In this example, the MEC weight for 2 years of data is used. 
subpopn ridageyr >= 50 ; 
Use the subpopn statement to select those ages 50 years and older. Please note that for accurate estimates of the standard error, it is preferable to use subpopn in SUDAAN to select a subgroup for analysis, rather than select the study subgroup SAS in a datastep when preparing the analytical data file. (See Section 5.4 of Korn and Graubard Analysis of Data from Health Surveys, pp 207211). 
class riagendr anycalsup treatosteo/NoFreq; 
Use the class statement for categorical variables in version 9.0. In earlier versions, you need a subgroup and levels statement. The NoFreq option suppresses printing frequencies in the output. 
table riagendr* anycalsup*treatosteo;

Use the table statement to choose the categorical variables gender (riagendr), supplement use (anycalsup) and osteoporosis treatment (treatosteo) for cross tabulation. 
print nsum rowper colper/tests=all;

Use the print statement to obtain the N, row percent (rowper),and column percent (colper). Use the tests option to request all available statistics. 
rformat riagendr gender. ; rformat anycalsup yesnos. ; rformat treatosteo yesno. ; 
Use the rformat statement to read the SAS formats into SUDAAN. 
rtitle "Chisquare test for calcium supplement use and osteoporosis: NHANES 20032004" ; run ; 
Use the rtitle statement to title the output. 
SUDAAN Version 9.0 proc crosstab provides only limited chisquare results (Wald) with pvalues based on unadjusted Fstatistics (not the recommended statistic for complex survey data). However, the SUDAAN regression procedures do produce the recommended F adjusted chisquare statistics (e.g. RaoScott and Satterthwaite) for use in analyzing NHANES data. SUDAAN Version 10 may have additional capabilities.