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: http://support.sas.com/ctx/samples/index.jsp?sid=483

 

 

Step 5: Set up SAS Survey Procedures Macro to Test for Significance

A t-test is used to test whether the mean SBP between males and females obtained in the previous step is statistically significant different.

Request the t-test from the SAS Survey %sregsub macro and follow the steps in the summary table below.

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.

 

Use SAS %sregsub Macro to Calculate Significance

Statements Explanation
%include 'C:\NHANES\sample00483_1_sregsub.sas.txt';

Use the %include function to include the macro text file. In this example, the file is named sample00483_1_sregsub.sas.txt and is saved in the C:\NHANES\ directory.

%SREGSUB(

This statement names and opens the macro, %sregsub.

DATA= analysis_data, 

Use the data statement to call in 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 the subpopulations of interest (i.e., 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.

MODEL=   bpxsar = riagendr,

Use a model statement to specify the dependent variable for systolic blood pressure (bpxsar) as a function of the independent variable gender (riagendr).

SUBPOP=  ridageyr >= 20,

Use the subpop statement to select those 20 years and older.

TITLE= 'Significance test for difference between mean systolic blood pressure for males and females NHANES 1999-2002'

);

Use the title statement to label the output.

 

information icon The ( ) and the = after the macro parameters, e.g., DATA=, are part of the %sregsub macro.

 

Step 65: Review Output

 

close window icon Close Window