Task 1: Produce Table of Race/Ethnicity and Gender by Linkage Eligibility and Match Status of NHANES Respondents: Medicare

Once the feasibility files have been merged to the NHANES demographic file you can use the merged files to assess sample sizes by different demographic characteristics (e.g. race/ethnicity and gender) and Medicare match status. These results can be used to determine the maximum available sample size so that the feasibility of conducting analyses utilizing the linked CMS Medicare data can be assessed. This should be especially useful when you initiate a RDC proposal to analyze the restricted use NHANES-CMS linked Medicare files.

Example: Produce a frequency distribution of race/ethnicity and gender from the NHANES Demographic file data.

Info icon Information

Because this table is being used to evaluate the adequacy of the sample, sample weights were not used.

Download, open and run the program, SAS Code for Medicare, linked below.


Explanation of SAS Code to Examine Contingency Table Cells
Statements Explanation
options ls=120 ps=42 missing=' ' nocenter validvarname=upcase compress=binary nodate nonumber; Log/List options.  Compress option reduces storage requirements for output datasets.
libname nhanes 'C:\NHANES'; Provides location for reading and saving SAS datasets.
proc format;
  value CMSMATCH
        1 = 'Linked'
        2 = 'Not Linked'
        3 = 'Ineligible';
  value GENDER
        1 = 'Male'
        2 = 'Female';

  value RACE_ONE
        1   = 'non-Hispanic white'
        2   = 'non-Hispanic black'
        3   = 'Mexican American'
        4   = 'Other';


Creates formats, CMS_MEDICARE_MATCH, GENDER, and RACE_ONE, based on the values of the variables CMS_ MEDICARE_MATCH, RIAGENDR and RACETH, respectively.
Race/ethnicity was recoded in Course 2, Module 7, Task 1 Merge.
proc tabulate data= nhanes.merg9900_Medicare The tabulate procedure is used to produce a formatted table displaying counts.
The default format for all cells is 10 spaces wide.
class RACETH    / order=unformatted missing;
class RIAGENDR  / order=unformatted missing;
class CMS_MEDICARE_MATCH / order=formatted missing;
The class statement identifies RACETH, RIAGENDR and CMS_ MEDICARE_MATCH as class variables, having a small number of discrete and unique values. 
The missing option alerts SAS to include observations with missing values in the table.  
The ORDER=UNFORMATTED option specifies that the class values are ordered by their unformatted values, which yields the same order as PROC SORT. The ORDER=FORMATTED option specifies that the class values are ordered by the formatted representation of the value.
table RIAGENDR RIDRETH1='Race/ethnicity' , /* Row Dimensions */
      CMS_ MEDICARE_MATCH*n;               
/* Column Dimension */
The table statement describes a two-dimensional table to be printed. 
The row dimension is composed of the total count, number of males and females, and number of race/ethnicity groups.
The column dimension is composed of CMS match status types.
format CMS_ MEDICARE_MATCH cmsmatch. RIAGENDR gender. RACETH race_one.; This format statement uses the user-written formats that have been previously defined in PROC FORMAT.
title 'Merged NHANES Feasibility/Demographic Data';
title2 'Frequency Distribution of Race/ethnicity and Gender by Medicare Match Status';
This title statement specifies a title for the output.


Check the results

To check the results of your program, review the SAS log and output (.lst) reports.

Output of program to examine contingency table cells

Your output should resemble the table below.  Note that the total count of NHANES-CMS Medicare eligible and linked respondents = 1,722. This number is confirmed in the match rate table on the NCHS website, referenced in Module 9, Task 2, Medicare, that shows that the number of 1999-2000 NHANES respondents linked at least one year of the Medicare Denominator File is also 1,722.

Merged NHANES Feasibility/Demographic Data

Frequency Distribution of Gender and Race/Ethnicity by CMS Medicare Match Status



‚                            ‚Ineligible‚  Linked  ‚Not Linked‚


‚Total                       ‚      2113‚      1722‚      6130‚


‚Gender                      ‚          ‚          ‚          ‚

‡ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒ‰          ‚          ‚          ‚

‚Male                        ‚       973‚       897‚      3013‚


‚Female                      ‚      1140‚       825‚      3117‚


‚Race/ethnicity              ‚          ‚          ‚          ‚

‡ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒ‰          ‚          ‚          ‚

‚non-Hispanic white          ‚       503‚       901‚      1963‚


‚non-Hispanic black          ‚       528‚       290‚      1410‚


‚Mexican American            ‚       865‚       414‚      2114‚


‚Other                       ‚       217‚       117‚       643‚




close window icon Close Window to return to module page.