Instructions: Step-by-Step Guide to Accessing NHAMCS-ED Public Use Data Files and Programs to Select Injury Records and Calculate Visit Rates


SAS and SUDAAN Programs for Variance Estimation

On this Page

Sample SAS and SUDAAN codes and documentation for variance estimation of complete NHAMCS-ED data.

Sample Codes for 2002-2005

PROC SORT DATA=xxx; /* replace xxx with the name that you want to use for your SAS dataset */
BY CSTRATM CPSUM;

PROC CROSSTAB DATA=xxx DESIGN=WR FILETYPE=SAS;
NEST CSTRATM CPSUM/MISSUNIT;
WEIGHT PATWT;
CLASS SEX; /* replace SEX with the variable that you would like to use */
TABLES SEX; /* replace SEX with the variable that you would like to use */
PRINT /STYLE=NCHS;
RUN;

Sample Codes for 1993-2001

Step 1

Since the two variables, “CSTRATM” & “CPSUM”, for variance estimation is not included in data files before 2002. The following program is needed to calculate them from existing variables from the public use data file. This code needs to be included in a SAS data step.

CSTRATM=STRATM;
CPSUM=PSUM;
IF CPSUM IN (1 2 3 4) THEN DO;
CSTRATM=(STRATM*100000)+(1000*(MOD(YEAR,100)))+
(SUBFILE*100)+PROSTRAT;
CPSUM=PROVIDER+100000;
END;
ELSE CSTRATM=(STRATM*100000);

Step 2

Sample SAS and SUDAAN codes for variance estimation

PROC SORT DATA=xxx; /* replace xxx with the name that you want to use for your SAS dataset */
BY CSTRATM CPSUM;

PROC CROSSTAB DATA=xxx DESIGN=WR FILETYPE=SAS;
NEST CSTRATM CPSUM/MISSUNIT;
WEIGHT PATWT;
CLASS SEX; /* replace SEX with the variable that you would like to use */
TABLES SEX; /* replace SEX with the variable that you would like to use */
PRINT /STYLE=NCHS;
RUN;

Page last reviewed: November 6, 2015