In this task, you will use SAS to calculate a tstatistic and assess whether the mean systolic blood pressure in calcium users vs. nonusers ages 20 years and older is statistically different.
This example uses the demoadv dataset (download at Sample Code and Datasets). The ttest is used with one continuous variable and one dichotomous variable. The dataset contains a created variable called 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). A variable called sel is created that defines those individuals 20 years old and older. Blood pressure is measured in the MEC; therefore MEC weights are used in the analysis. The demoadv dataset for this example only includes those with MEC weights (wtmec2yr>0):
data demoadv;
set nh.demoadv;
if wtmec2yr> 0 ;
if ridageyr >= 20 then sel= 1 ;
else sel= 2 ;
run ;
Statements  Explanation 

proc surveymeans data =demoadv nobs mean stderr ; 
Use the proc surveymeans procedure to obtain number of observations, mean, and standard error. 
stratum sdmvstra; 
Use the stratum statement to define the strata variable (sdmvstra). 
cluster sdmvpsu; 
Use the cluster statement to define the PSU variable (sdmvpsu). 
class anycalsup; 
Use the class statement to specify the discrete variables used to form the subpopulations of interest. In this example, the subpopulation of interest is by supplement use (anycalsup). 
domain sel sel*anycalsup; 
Use the domain statement to specify the table layout to form the subpopulations of interest. This example uses age greater than or equal to 20 (sel) by supplement use (anycalsup). 
var mean_sbp; 
Use the var statement to name the variable(s) to be analyzed. In this example, the mean systolic blood pressure variable (mean_sbp) is used. 
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 (wtmec2yr) is used. 
format anycalsup yesnos. ; 
Formats the anycalsup variable. 
Highlights from the output include:
A ttest is used to test whether the mean systolic blood pressure in calcium supplement users is statistically different from the mean systolic blood pressure in nonusers. In SAS, a simple linear model using proc surveyreg may be used to obtain the ttest.
Statements  Explanation 

proc surveyreg data =demoadv ; 
Use the proc surveyreg procedure to obtain number of observations, mean, and standard error. 
stratum sdmvstra; 
Use the stratum statement to define the strata variable (sdmvstra). 
cluster sdmvpsu; 
Use the cluster statement to define the PSU variable (sdmvpsu). 
model mean_sbp=anycalsup;

Use the model statement to specify the outcome variable (mean_sbp) and the 2level variable used to form the subpopulation of interest. In this example, the subpopulation of interest is by supplement use (anycalsup). 
domain sel; 
Use the domain statement to specify the table layout to form the subpopulations of interest. This example uses age greater than or equal to 20 (sel) by supplement use (anycalsup). 
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 (wtmec2yr) is used. 
format anycalsup yesnos. ; 
Formats the anycalsup variable. 
Highlights from the output include: