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


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 Medicaid match status. These results can be used to determine the maximum available sample size so that the feasibility of conducting analyses utilizing the NHANES-CMS linked Medicaid data can be assessed. This should be especially useful when you initiate a RDC proposal to analyze the restricted use linked CMS Medicaid 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 Medicaid, 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_MEDICAID_MATCH, GENDER, and RACE_ONE, based on the values of the variables CMS_ MEDICAID_MATCH, RIAGENDR and RACETH (re-coded race/ethnicity variable), respectively. Race/ethnicity was recoded in Course 2, Module 7, Task 1 Merge.
proc tabulate data= nhanes.merg9900_Medicaid The tabulate procedure is used to produce a formatted table displaying total counts.
format=BEST10.0; The default format for all cells is 10 spaces wide.
class RACETH  / order=unformatted missing;
class RIAGENDR / order=unformatted missing;
class CMS_MEDICAID_MATCH / order=formatted missing;
The class statement identifies RACETH, RIAGENDR and CMS_ MEDICAID_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_ MEDICAID_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 Medicaid match status.
format CMS_ MEDICAID_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 Medicaid Match Status'';
This title statement specifies the title of 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 Medicaid eligible and linked respondents = 3,506. This number is confirmed in the match rate table on the NCHS website, referenced in Module 9, Task 2, Medicaid, that shows that the number of 1999-2000 NHANES respondents linked to at least one year of the Medicaid Person Summary File is also 3,506.


‚                            ‚Ineligible‚  Linked  ‚Not Linked‚


‚Total                       ‚      2113‚      3506‚      4346‚


‚Gender                      ‚          ‚          ‚          ‚

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

‚Male                        ‚       973‚      1520‚      2390‚


‚Female                      ‚      1140‚      1986‚      1956‚


‚Race/Ethnicity (recode)     ‚          ‚          ‚          ‚

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

‚non-Hispanic white          ‚       503‚       713‚      2151‚


‚non-Hispanic black          ‚       528‚      1009‚       691‚


‚Mexican American            ‚       865‚      1377‚      1151‚


‚Other                       ‚       217‚       407‚       353‚


close window icon Close Window to return to module page.