Task 1b: How to Set Up a t-test in NHANES Using SAS 9.1 Survey Procedures

In this task, you will use SAS Survey Procedures to calculate a t-statistic and assess whether the mean systolic blood pressures (SBP) in males and females age 20 years and older are statistically different.

 

Step 1: Create Variable to Subset Population

In order to subset the data in SAS Survey Procedures, you will need to create a variable for the population of interest. In this example, the sel variable is set to 1 if the sample person is 20 years or older, and 2 if the sample person is younger than 20 years. Then this variable is used in the domain statement to specify the population of interest (those 20 years and older).

if ridageyr GE 20 then sel = 1;

else sel = 2;

 

Step 2: Set Up SAS Survey Procedures to Produce Means

Follow the explanations in the summary table below to produce the mean SBP using the SAS Survey procedure proc surveymeans.

 

information icon 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.


SAS proc surveymeans Procedure for Means

Statements Explanation
proc surveymeans data=analysis_data nobs mean stderr;

 

Use the SAS Survey procedure, proc surveymeans, to count the number of observations (nobs) and calculate means (mean) and standard errors (stderr), and specify the dataset (analysis_Data).

strata sdmvstra;

                                           

 

Use the strata statement to specify the strata (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.

class riagendr;

Use the class statement to specify the discrete variables used to select from the subpopulations of interest. In this example, the subpopulation of interest are gender (riagendr).

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.

domain sel sel*riagendr; 

Use the domain statement to select those 20 years and older (sel) by gender (riagendr).

warning icon When using proc surveymeans, use a domain statement to select the population of interest. Do not use a where or by-group statement to analyze subpopulations with the SAS Survey Procedures.
var bpxsar;

 

Use the var statement to indicate variable(s) for which descriptive measures are requested. In this example, the systolic blood pressure variable (bpxsar) is used.

ods output domain(match_all)=domain;

Use the ods statement to output the dataset of estimates from the subdomains listed on the domain statement above. This set of commands will output two datasets for each subdomain specified in the domain statement above (domain for sel; domain1 for sel*riagendr).

data all;

set domain domain1;

if sel=1;

Use the data statement to name the temporary SAS dataset (all) to append the two datasets, created in the previous step, if age is greater than or equal to 20 (sel).

proc print;

var riagendr n mean stderr;

title "Mean systolic blood pressure: NHANES 1999-2002";

run;

Use the print statement to print the number of observations, the mean, and standard error of the mean in a printer-friendly format.

 

 

Step 3: Review SAS Means Output

 

Step 4: Download SAS %sregsub Macro Text File

Because version 9.1 of SAS Survey Procedures for proc surveyreg does not have a domain statement for subpopulation analyses (a domain statement is being added to proc surveyreg in SAS v9.2), you will need to use a macro provided on the SAS website. Download the file, save it to your computer, and make sure to note the location, as you will be referring your SAS program to the file later.

   Link to %sregsub macro on SAS website: