In this task, you will use the chi-square test to determine whether age group and osteoporosis treatment status are independent of each other.

Before running any SUDAAN procedure, sort the data by strata and PSUs, using the PROC SORT procedure.

The PROC CROSSTAB procedure is used in SUDAAN to examine the relationship between two categorical variables. The chi-square statistic is requested from this procedure as well.

Use the NEST statement to account for the design effects and the WEIGHT statement to account for the unequal probability of sampling and non-response. Use the SUBPOPN statement to select the subpopulation of interest. Note that for accurate estimates of the standard error, it is preferable to use the SUBPOPN statement in SUDAAN to select a subgroup for analysis, rather than select the study subgroup in SAS when preparing the data file.

Use the CLASS statement to list the categorical variables and the table statement to create a cross tab of the categorical variables age group (AGEGRP) and osteoporosis treatment status (TREATOSTEO). Use the TABLE statement to create a cross tab of the categorical variables gender (RIAGENDR) and osteoporosis treatment status (TREATOSTEO). Use the PRINT statement to obtain the number of observations (NSUM), row percent (ROWPER), and column percent (COLPER). Use the TESTS option to request all available statistics.

Use the RFORMAT statement to apply the sex format to the RIAGENDR variable. Use the RTITLE statement to title the output.

*-------------------------------------------------------------------------;

* Use the PROC SORT procedure to sort the data files by strata and
PSU. ;

* Data must always be sorted before running a SUDAAN
procedure. ;

*
;

* Use the PROC CROSSTAB procedure to perform a chi-square test in
SUDAAN. ;

* This test will be used to determine whether gender and treatment
for ;

* osteoporosis are independent of each other in respondents aged 20
and ;

*
over.
;

*-------------------------------------------------------------------------;

**
nest SDMVSTRA SDMVPSU;
weight
WTINT2YR;
subpopn RIDAGEYR >=
20 ;
class
AGEGRP TREATOSTEO/nofreq;
table
AGEGRP*TREATOSTEO;
print nsum rowper colper/tests=all;
rformat AGEGRP
AGEGRP. ;
rformat TREATOSTEO
YESNO. ;
rtitle
"Chi-square test for osteoporosis treatment by age group"
"among people >= 20 years of age" ;
; **
data=DEMOOSTS design=wr;

```
Number of observations read : 10122 Weighted count :286222757
Observations in subpopulation : 5041 Weighted count:205284669
Denominator degrees of freedom : 15
Variance Estimation Method: Taylor Series (WR)
For Subpopulation: RIDAGEYR >= 20
Chi-square test for osteoporosis treatment by age group among people >= 20 years of age
by: Age of subject, Subject is being treated for osteoporosis.
-----------------------------------------------------------------------
| | |
| Age of subject | | Subject is being treated for
| | | osteoporosis
| | | Total | Yes | No |
-----------------------------------------------------------------------
| | | | | |
| Total | Sample Size | 5023 | 265 | 4758 |
| | Row Percent | 100.00 | 4.18 | 95.82 |
| | Col Percent | 100.00 | 100.00 | 100.00 |
-----------------------------------------------------------------------
| | | | | |
| 20-39 | Sample Size | 1740 | 2 | 1738 |
| | Row Percent | 100.00 | 0.24 | 99.76 |
| | Col Percent | 38.90 | 2.21 | 40.50 |
-----------------------------------------------------------------------
| | | | | |
| 40-59 | Sample Size | 1394 | 36 | 1358 |
| | Row Percent | 100.00 | 2.61 | 97.39 |
| | Col Percent | 38.51 | 24.06 | 39.14 |
-----------------------------------------------------------------------
| | | | | |
| >= 60 | Sample Size | 1889 | 227 | 1662 |
| | Row Percent | 100.00 | 13.65 | 86.35 |
| | Col Percent | 22.58 | 73.73 | 20.35 |
-----------------------------------------------------------------------
Chi-square test for osteoporosis treatment by age group among people >= 20 years of age
Chi Square Test of Independence for Age of subject and Subject is being treated for osteoporosis
-------------------------------------------------
| | |
| | | |
-------------------------------------------------
| | | |
| | ChiSq | 91.25 |
| | P-value ChiSq | 0.0000 |
| | Degrees of | |
| | Freedom ChiSq | 2 |
| | LLChiSq | 1216.95 |
| | P-value LLChiSq | 0.0000 |
| | Degrees of | |
| | Freedom LLChiSq | 2 |
-------------------------------------------------
```

Highlights from the output include:

- 5,041 respondents were included in this analysis.
- The row percentages indicate that persons greater than or equal to 60 years of age are more likely to have been treated for osteoporosis compared to younger persons.
- Because the p-value is less than 0.05, the null hypothesis is rejected at the 0.05 level and it is concluded that age group and treatment for osteoporosis status are significantly associated.

Close Window to return to module page.