U.S. Department of Health and Human Services  www.hhs.gov
Agency for Healthcare Research Quality www.ahrq.gov
MEPS Home Medical Expenditure Panel Survey
Font Size:
Contact MEPS FAQ Site Map  

SAS® Programming Examples from MEPS Data Users Workshops

On this page: Estimation - Employment - Linking - Miscellaneous

At MEPS data users workshops, MEPS staff demonstrate how to develop estimates using the public use files and how to construct MEPS analytic files using SAS. They also assist attendees in the construction of estimates and analytic files for their own research.

Provided below are SAS programming examples used in recent MEPS workshops. As with the workshops themselves, to benefit from these examples you should have a working knowledge of SAS. Each example is available as SAS programming statements or as SAS output (PDF or HMTL formats) with the program log and listings. The SAS file is the program code that performs the stated task; to run this program you will need SAS on your computer. The PDF and HTML files provide both the annotated SAS program and the resulting output; you do not need to have SAS on your computer to view these files. The *new releases and **updated PDF files maintain a standard SAS structured layout format containing indents for ease of reading whereas the HTML files are formatted for accessibility purposes and are therefore not recommended for normal viewing and printing.

Estimation Examples   SAS® PDF
Compute person-level estimates for healthcare expenditures. Estimates include: Means, Proportions, Totals.   E1.sas (4.1 KB) E1.pdf (45 KB) E1.html
Compute average total healthcare expenditures for children ages 0-5 for the 4 years 1996 – 1999.   E2.sas (5.9 KB) E2.pdf (58 KB) E2.html
Create a longitudinal file for 1999-2000 (Panel 4) and compute person-level estimates for insurance coverage and expenditures.   E3.sas (3.5 KB) E3.pdf (42 KB) E3.html
Compute family-level estimates for healthcare expenditures based on family size.   E4.sas (3.4 KB) E4.pdf (44 KB) E4.html
Compute event-level expenditure estimates for inpatient hospital stay events and for office-based medical provider visits.   E5.sas (2.2 KB) E5.pdf (37 KB) E5.html
Compute 2005 national health care expenditures by type of service as reported in Statistical Brief #193. * E6.sas (3.9 KB) E6.pdf (12 KB) E6.html
Compute 2005 colonoscopy screening estimates as reported in Statistical Brief #188. * E7.sas (5.4 KB) E7.pdf (20 KB) E7.html
Compute 2005 inpatient stays expenditures by source of payment, per stay, per diem, with and without surgery. Statistical Brief #164 reports a similar set of statistics but for 2004. * E8.sas (5.3 KB) E8.pdf (17 KB) E8.html

Return to Top

Employment Examples   SAS® PDF
Build an analytic file to look at the relationship between health status and current main job weekly earnings.   EM1.sas (4.9 KB) EM1.pdf (47 KB) EM1.html
Determine how many people working at the beginning of 2002 changed jobs.   EM2.sas (3.5 KB) EM2.pdf (41 KB) EM2.html

Return to Top

Linking Examples   SAS® PDF
Merge the 2001 MEPS full-year file and the 2001 MEPS Jobs file to count the number of jobs for each person in the first part of 2001.   L1.sas (4.0 KB) L1.pdf (47 KB) L1.html
Combine the 2000 and 2001 MEPS Jobs files to identify 2001 jobs first reported in 2000 and update 2001 file information for those jobs.   L1A.sas (3.7 KB) L1A.pdf (62 KB) L1A.html
Use the NHIS-MEPS Link File to link 2001 MEPS data with 1999 and 2000 NHIS data.   L2.sas (4.7 KB) L2.pdf (136 KB) L2.html
Merge data from the 2001 MEPS Office-based Medical Provider Visits file with data from the 2001 MEPS full-year file. Aggregate event-level data to the person level.   L3.sas (3.7 KB) L3.pdf (45 KB) L3.html
Merge data from the 2001 MEPS Medical Conditions file with data from the 2001 MEPS full-year file.   L4.sas (3.5 KB) L4.pdf (60 KB) L4.html
Merge data from the 2001 MEPS Medical Conditions file with data from the 2001 MEPS full-year file and with data from various 2001 MEPS event files (prescribed medicines, emergency room visits, outpatient visits, and office-based medical provider visits).   L5.sas (6.0 KB) L5.pdf (53 KB) L5.html

Return to Top

Miscellaneous Examples   SAS® PDF
Shows the need for using weight variables when analyzing MEPS data for national estimates. ** M1.sas (1.8 KB) M1.pdf (9.8 KB) M1.html
Shows the need for using the STRATUM and PSU variables when analyzing MEPS data for national estimates. That is, taking the MEPS complex design properties into account. ** M2.sas (2.0 KB) M2.pdf (10 KB) M2.html
Shows the use of id variables on different MEPS public-use files (pufs) and how to use these id variables to merge MEPS files. ** M3.sas (4.3 KB) M3.pdf (16 KB) M3.html
Illustrates two ways of determining the number of events associated with conditions. (1) using the evNUM variables on the CONDITIONS file. (2) using the number of matches between the CONDITIONS file and the CLINK file.   M4.sas (3.4 KB) M4.pdf (22 KB) M4.html
Shows the difference between two uses of the term "priority condition" in MEPS. ** M5.sas (7.4 KB) M5.pdf (17 KB) M5.html
Shows the use of the Diabetes Care Supplement (DCS) weight variable, diabw05f) for generating estimates for analyses using questions from the DCS. ** M6.sas (2.1 KB) M6.pdf (9.5 KB) M6.html
Shows how to compute person-level prescribed medicine expenditures for persons with at least one PMED event.   M7.sas (3.3 KB) M7.pdf (22 KB) M7.html
Shows how to compute prescribed medicine expenditures associated with cancer conditions. ** M8.sas (8.3 KB) M8.pdf (22 KB) M8.html
Uses the 2005 full-year file to output descriptive statistics showing health insurance status and healthcare utilization. ** M9.sas (3.2 KB) M9.pdf (12 KB) M9.html
Compares hospital inpatient expenditures (facility, physician, total) for stays that do and do not include facility expenditures for the preceding emergency room visit.   M10.sas (2.5 KB) M10.pdf (21 KB) M10.html
Shows how to merge parents' employment status variable EMPST31 to children's records by using the MOPID31 and DAPID31 variables.
* M11.sas (5.41 KB) M11.pdf (67 KB) M11.html

* - New release

** - Updated

Return to Top

Public use files used in the SAS® programming examples

PUF no. Data year File name
1996 Full-Year Consolidated Data E2
H20 1997 Full-Year Consolidated Data E2
H28 1998 Full-Year Consolidated Data E2
H38 1999 Full-Year Consolidated Data E2, E3
H40 2000 Jobs File L1A
H50 2000 Full-Year Consolidated Data E3
H56 2001 Jobs File L1, L1A
H59a 2001 Prescribed Medicines L5
H59d 2001 Hospital Inpatient Stays E5
H59e 2001 Emergency Room Visits L5
H59f 2001 Outpatient Visits L5
H59g 2001 Office-Based Provider Visits E5, L3, L5
H59i 2001 CLNK File L5
H60 2001 Full-Year Consolidated Data E1, E4, L1, L2, L3, L4, L5
H61 2001 Medical Conditions L4, L5
H62 2002 Full-Year Population Characteristics EM1, EM2
H63 2002 Jobs File EM2
H36 1996–2002 1996–2002 Pooled Estimation File E2
H58 1999–2000 Panel 4 Longitudinal Data File E3
H77A 2003 Prescribed Medicines File M7
H77D 2003 Hospital Inpatient Stays M10
H77IF1 2003 Condition - Event Link Files (CLINK) M4
H78 2003 Medical Conditions File M4
H79 2003 Full Year Consolidated Data File M7
H94A 2005 Prescribed Medicines File M8
H94D 2005 Hospital Inpatient Stays E8
H94I 2005 Condition - Event Link Files (CLINK) M8
H96 2005 Medical Conditions File M3, M5, M8
H97 2005 Full Year Consolidated Data File M1, M2, M3, M5, M6, M8, M9, E6, E7, E8
NHISPER99.DAT 1999 NHIS Person File L2
NHISPER00.DAT 2000 NHIS Person File L2
NHMEP01X.DAT 1999–2000 NHIS–MEPS Link File L2

Return to Top


The SAS programs contain LIBNAME statements which specify the directory location of the input data. For these examples the directory is "C:\MEPS\DATA". You will need to specify the directory information that corresponds to your own system.

The LIBNAME statement also creates a name by which the directory location is referred to in the remainder of the program. For these examples the name is "CMEPS". In the program examples you will see particular data files referred to by "CMEPS.filename" where filename is the name for a particular data file.

The MEPS public use data files used in these examples are from the MEPS Household Component (HC) and are referred to by an initial "H" or "HC-" and then the number assigned to the particular file. The first column in the table above gives the names of the files used in the programs. As with the directory specifications, filenames used in your programs will need to correspond to the names of the files on your system.

All MEPS public use files and file documentation are available for download.

Return to Top