/************************************************************************************************/
/* Stata User File for H208 Data                                                                 */
/*                                                                                              */
/* This file contains information and a sample Stata program to create a permanent              */
/* Stata dataset for users who want to use Stata in processing the MEPS data provided           */
/* in this PUF release.  Stata (StataCorp) has the capability to produce                        */
/* appropriate standard errors for estimates from a survey with a complex sample                */
/* design such as the Medical Expenditure Panel Survey (MEPS).                                  */
/* The input file for creating a permanent Stata dataset is the ASCII data file                 */
/* (H208.DAT) supplied in this PUF release, which in turn can be extracted from the              */
/* .EXE file. After entering the Stata interactive environment access the Stata DO-File         */
/* editor by clicking on the appropriate icon in the command line at the top of the             */
/* screen.  Copy and paste the following Stata commands into the editor and save as a           */
/* DO file.  A DO file is a Stata program which may then be executed using the DO command.      */
/* For example, if the DO file is named H208.DO and is located in the directory                  */
/* C:\MEPS\PROG, then the file may be executed by typing the following command into             */
/* the Stata command line:                                                                      */
/*                         do C:\MEPS\PROG\H208.DO                                               */
/* The program below will output the Stata dataset H208.DTA                                      */
/************************************************************************************************/


#delimit ;
cd C:\MEPS\DATA;
log using H208.log, replace;
clear;

* INPUT ALL VARIABLES;
infix
  str    EPCPIDX 1-35
  str    DUPERSID 36-45
  str    PHLDRIDX 46-55
  str    ESTBIDX 56-66
  str    EPRSIDX 67-91
  str    InsurPrivIDEX 92-105
  str    EPCPIDX_17 106-133
  str    DUPERSID_17 134-141
  str    PHLDRIDX_17 142-149
  str    ESTBIDX_17 150-160
  str    EPRSIDX_17 161-180
  str    JOBSIDX_17 181-191
  byte   PANEL 192-193
  byte   RN 194-194
  str    JOBSIDX 195-208
  byte   JOBSINFR 209-210
  int    JOBSFILE 211-213
  byte   PITFLG 214-214
  byte   FYFLG 215-215
  byte   CMJINS 216-217
  int    EMPLSTAT 218-220
  byte   PHOLDER 221-221
  byte   DEPNDNT 222-222
  byte   PHLDRCHNG 223-224
  byte   EVALCOVR 225-226
  byte   STATUS1 227-228
  byte   STATUS2 229-230
  byte   STATUS3 231-232
  byte   STATUS4 233-234
  byte   STATUS5 235-236
  byte   STATUS6 237-238
  byte   STATUS7 239-240
  byte   STATUS8 241-242
  byte   STATUS9 243-244
  byte   STATUS10 245-246
  byte   STATUS11 247-248
  byte   STATUS12 249-250
  byte   STATUS13 251-252
  byte   STATUS14 253-254
  byte   STATUS15 255-256
  byte   STATUS16 257-258
  byte   STATUS17 259-260
  byte   STATUS18 261-262
  byte   STATUS19 263-264
  byte   STATUS20 265-266
  byte   STATUS21 267-268
  byte   STATUS22 269-270
  byte   STATUS23 271-272
  byte   STATUS24 273-274
  byte   DECPHLDR 275-275
  byte   OUTPHLDR 276-276
  byte   NOPUFLG 277-277
  byte   COVROUT_M18 278-279
  byte   TYPEFLAG 280-281
  byte   STEXCH 282-283
  byte   STSHOP 284-285
  byte   PrivateCat 286-287
  byte   PRIVCAT 288-289
  byte   HOSPINSX 290-291
  byte   MSUPINSX 292-293
  byte   DENTLINS 294-295
  byte   VISIONIN 296-297
  byte   PMEDINS 298-299
  int    COBRA 300-302
  byte   PLANMETL 303-304
  byte   COVTYPIN 305-305
  byte   OOPELIG 306-306
  double OOPPREM 307-314
  double OOPPREMX 315-321
  double OOPX12X 322-329
  byte   OOPFLAG 330-331
  int    PREMLEVX 332-334
  byte   PREMSUBZ 335-336
  str    ANNDEDCT 337-339
  byte   HSAACCT 340-341
  int    UPRHMO 342-344
  byte   NAMECHNG 345-346
using H208.dat;

*DEFINE VARIABLE LABELS;
label variable EPCPIDX "Insurance source-phldr-dependent identifier";
label variable DUPERSID "Person identifier";
label variable PHLDRIDX "Policyholder person identifier";
label variable ESTBIDX "Insurance source identifier";
label variable EPRSIDX "Unique Insurance Policy-Source";
label variable InsurPrivIDEX "Unique insurance source-insurance identifier";
label variable EPCPIDX_17 "2017 PRPL file EPCPIDX";
label variable DUPERSID_17 "2017 PRPL file DUPERSID";
label variable PHLDRIDX_17 "2017 PRPL file PHLDRIDX";
label variable ESTBIDX_17 "2017 PRPL file ESTBIDX";
label variable EPRSIDX_17 "2017 PRPL file EPRSIDX";
label variable JOBSIDX_17 "2017 PRPL file JOBSIDX";
label variable PANEL "Panel number";
label variable RN "Round number";
label variable JOBSIDX "Policyholder job-round identifier";
label variable JOBSINFR "Job identifier inferred not reported";
label variable JOBSFILE "Jobs file containing job information";
label variable PITFLG "Person in point-in-time file";
label variable FYFLG "Person in full year file";
label variable CMJINS "Current main job is the source of plan";
label variable EMPLSTAT "Policyholder employment status";
label variable PHOLDER "Policy holder flag";
label variable DEPNDNT "Dependent of policy holder flag";
label variable PHLDRCHNG "Change to PHLDRIDX on reviewed coverage";
label variable EVALCOVR "Covered at interview or December 31st";
label variable STATUS1 "Insurance active in month 1";
label variable STATUS2 "Insurance active in month 2";
label variable STATUS3 "Insurance active in month 3";
label variable STATUS4 "Insurance active in month 4";
label variable STATUS5 "Insurance active in month 5";
label variable STATUS6 "Insurance active in month 6";
label variable STATUS7 "Insurance active in month 7";
label variable STATUS8 "Insurance active in month 8";
label variable STATUS9 "Insurance active in month 9";
label variable STATUS10 "Insurance active in month 10";
label variable STATUS11 "Insurance active in month 11";
label variable STATUS12 "Insurance active in month 12";
label variable STATUS13 "Insurance active in month 13";
label variable STATUS14 "Insurance active in month 14";
label variable STATUS15 "Insurance active in month 15";
label variable STATUS16 "Insurance active in month 16";
label variable STATUS17 "Insurance active in month 17";
label variable STATUS18 "Insurance active in month 18";
label variable STATUS19 "Insurance active in month 19";
label variable STATUS20 "Insurance active in month 20";
label variable STATUS21 "Insurance active in month 21";
label variable STATUS22 "Insurance active in month 22";
label variable STATUS23 "Insurance active in month 23";
label variable STATUS24 "Insurance active in month 24";
label variable DECPHLDR "Deceased policyholder flag";
label variable OUTPHLDR "Out-of-RU policyholder flag";
label variable NOPUFLG "Policyholder not in full year or point-in-time files";
label variable COVROUT_M18 "Policy covers person not in RU";
label variable TYPEFLAG "Type of insurance source";
label variable STEXCH "State exchange coverage";
label variable STSHOP "Small business establishment-related health ins";
label variable PrivateCat "Category of private coverage";
label variable PRIVCAT "Category of private coverage (prior to 2018)";
label variable HOSPINSX "Type health insurance received: hospital phys/HMO (edited)";
label variable MSUPINSX "Type health insurance received: Medigap (edited)";
label variable DENTLINS "Type health insurance received: dental";
label variable VISIONIN "Type health insurance received: vision";
label variable PMEDINS "Type health insurance received: prescription drug";
label variable COBRA "COBRA coverage";
label variable PLANMETL "Plan metal level";
label variable COVTYPIN "Single or family health insurance coverage plan";
label variable OOPELIG "Policyholder-insurance source has premium";
label variable OOPPREM "Monthly out-of-pocket premium";
label variable OOPPREMX "Monthly out-of-pocket premium (edited/imputed)";
label variable OOPX12X "Annual out-of-pocket premium (edited/imputed)";
label variable OOPFLAG "OOPPREMX edit/imputation flag";
label variable PREMLEVX "Portion of premium paid by family (edited)";
label variable PREMSUBZ "Cost of the premium subsidized";
label variable ANNDEDCT "Annual deductible";
label variable HSAACCT "HSA with this plan";
label variable UPRHMO "HMO coverage (edited)";
label variable NAMECHNG "Plan name change";


*DEFINE VALUE LABELS FOR REPORTS;
label define H2080001X
         -1 "-1 INAPPLICABLE"
         1 "1 YES"
         2 "2 NO" ;

label define H2080002X
         -1 "-1 INAPPLICABLE"
         -15 "-15 CANNOT BE COMPUTED"
         -7 "-7 REFUSED"
         -8 "-8 DK"
         1 "1 YES"
         2 "2 NO" ;

label define H2080003X
         -1 "-1 INAPPLICABLE"
         -15 "-15 CANNOT BE COMPUTED"
         -7 "-7 REFUSED"
         -8 "-8 DK"
         1 "1 YES"
         2 "2 NO" ;

label define H2080004X
         1 "1 SINGLE"
         2 "2 FAMILY" ;

label define H2080005X
         1 "1 YES"
         2 "2 NO" ;

label define H2080006X
         -1 "-1 INAPPLICABLE"
         -15 "-15 CANNOT BE COMPUTED"
         -7 "-7 REFUSED"
         -8 "-8 DK"
         1 "1 YES"
         2 "2 NO" ;

label define H2080007X
         0 "0 POLICYHOLDER"
         1 "1 DEPENDENT" ;

label define H2080008X
         -1 "-1 INAPPLICABLE"
         -15 "-15 CANNOT BE COMPUTED"
         -7 "-7 REFUSED"
         -8 "-8 DK"
         1 "1 CURRENTLY EMPLOYED"
         2 "2 RETIRED"
         3 "3 PREVIOUSLY EMPLOYED"
         4 "4 DECEASED"
         91 "91 OTHER" ;

label define H2080009X
         -1 "-1 INAPPLICABLE"
         1 "1 YES"
         2 "2 NO" ;

label define H2080010X
         0 "0 NO"
         1 "1 YES" ;

label define H2080011X
         -1 "-1 INAPPLICABLE"
         -15 "-15 CANNOT BE COMPUTED"
         -7 "-7 REFUSED"
         -8 "-8 DK"
         1 "1 YES"
         2 "2 NO" ;

label define H2080012X
         -1 "-1 INAPPLICABLE"
         -15 "-15 CANNOT BE COMPUTED"
         -7 "-7 REFUSED"
         -8 "-8 DK"
         1 "1 YES"
         2 "2 NO" ;

label define H2080013X
         -1 "-1 INAPPLICABLE"
         195 "HC195 2017 JOBSFILE"
         203 "HC203 2018 JOBSFILE" ;

label define H2080014X
         -1 "-1 INAPPLICABLE"
         0 "0 NO"
         1 "1 YES" ;

label define H2080015X
         -1 "-1 INAPPLICABLE"
         -15 "-15 CANNOT BE COMPUTED"
         -7 "-7 REFUSED"
         -8 "-8 DK"
         1 "1 YES"
         2 "2 NO" ;

label define H2080016X
         -1 "-1 INAPPLICABLE"
         -15 "-15 CANNOT BE COMPUTED"
         -7 "-7 REFUSED"
         -8 "-8 DK"
         1 "1 YES"
         2 "2 NO" ;

label define H2080017X
         1 "1 YES"
         2 "2 NO" ;

label define H2080018X
         1 "1 YES"
         2 "2 NO" ;

label define H2080019X
         -1 "-1 INAPPLICABLE"
         0 "0 NO"
         1 "1 YES" ;

label define H2080020X
         -1 "-1 INAPPLICABLE"
         -15 "-15 CANNOT BE COMPUTED"
         -7 "-7 REFUSED"
         -8 "-8 DK"
         0 "0 NO PREMIUM CONTRIBUTION" ;

label define H2080021X
         -1 "-1 INAPPLICABLE"
         0 "0 NO PREMIUM CONTRIBUTION" ;

label define H2080022X
         -1 "-1 INAPPLICABLE"
         0 "0 NO PREMIUM CONTRIBUTION" ;

label define H2080023X
         1 "1 YES"
         2 "2 NO" ;

label define H2080024X
         22 "22"
         23 "23" ;

label define H2080025X
         -1 "-1 INAPPLICABLE"
         1 "1 CHANGED FROM 902 TO NON 902"
         2 "2 CHANGED FROM NON 902 TO 902"
         3 "3 CHANGED FROM NON 902 TO 901"
         4 "4 CHANGED FROM NON 902 TO NON 902"
         5 "5 MULTIPLE POLICYHOLDERS ARE REPORTED" ;

label define H2080026X
         0 "0 DEPENDENT"
         1 "1 POLICYHOLDER" ;

label define H2080027X
         0 "0 NO"
         1 "1 YES" ;

label define H2080028X
         -1 "-1 INAPPLICABLE"
         -15 "-15 CANNOT BE COMPUTED"
         -7 "-7 REFUSED"
         -8 "-8 DK"
         1 "1 PLATINUM PLAN"
         2 "2 GOLD PLAN"
         3 "3 SILVER PLAN"
         4 "4 BRONZE PLAN"
         5 "5 CATASTROPHIC PLAN"
         6 "6 IF VOLUNTEERED: SOMETHING ELSE" ;

label define H2080029X
         -1 "-1 INAPPLICABLE"
         -15 "-15 CANNOT BE COMPUTED"
         -7 "-7 REFUSED"
         -8 "-8 DK"
         1 "1 YES"
         2 "2 NO" ;

label define H2080030X
         -1 "-1 INAPPLICABLE"
         -15 "-15 CANNOT BE COMPUTED"
         -7 "-7 REFUSED"
         -8 "-8 DK"
         1 "1 FAMILY PAYS ALL PREMIUM COST"
         2 "2 FAMILY PAYS SOME PREMIUM COST"
         3 "3 FAMILY DOES NOT KNOW"
         4 "4 FAMILY DOES NOT PAY PREMIUM COST" ;

label define H2080031X
         -1 "-1 INAPPLICABLE"
         -15 "-15 CANNOT BE COMPUTED"
         -7 "-7 REFUSED"
         -8 "-8 DK"
         1 "1 YES"
         2 "2 NO" ;

label define H2080032X
         -1 "-1 INAPPLICABLE"
         0 "0 NOT HOSP/PHYS OR MEDIGAP COVERAGE"
         1 "1 EMPLOYER/UNION"
         2 "2 NONGROUP"
         3 "3 OTHER GROUP"
         4 "4 OUT OF HOUSEHOLD"
         5 "5 SELF-EMPLOYED"
         6 "6 STATE EXCHANGE"
         99 "99 DONT KNOW WHAT KIND PRIV COV" ;

label define H2080033X
         0 "0 NOT HOSP/PHYS OR MEDIGAP COVERAGE"
         1 "1 EMPLOYER/UNION"
         2 "2 NONGROUP"
         3 "3 OTHER GROUP"
         4 "4 ESI, PHOLDER OUTSIDE RU"
         5 "5 NON-ESI, PHOLDER OUTSIDE RU"
         6 "6 STATE EXCHANGE"
         99 "99 DONT KNOW WHAT KIND PRIV COV" ;

label define H2080034X
         1 "1"
         2 "2"
         3 "3"
         4 "4"
         5 "5" ;

label define H2080035X
         -1 "-1 INAPPLICABLE"
         1 "1 YES"
         2 "2 NO" ;

label define H2080036X
         -1 "-1 INAPPLICABLE"
         1 "1 YES"
         2 "2 NO" ;

label define H2080037X
         -1 "-1 INAPPLICABLE"
         1 "1 YES"
         2 "2 NO" ;

label define H2080038X
         -1 "-1 INAPPLICABLE"
         1 "1 YES"
         2 "2 NO" ;

label define H2080039X
         -1 "-1 INAPPLICABLE"
         1 "1 YES"
         2 "2 NO" ;

label define H2080040X
         -1 "-1 INAPPLICABLE"
         1 "1 YES"
         2 "2 NO" ;

label define H2080041X
         -1 "-1 INAPPLICABLE"
         1 "1 YES"
         2 "2 NO" ;

label define H2080042X
         -1 "-1 INAPPLICABLE"
         1 "1 YES"
         2 "2 NO" ;

label define H2080043X
         -1 "-1 INAPPLICABLE"
         1 "1 YES"
         2 "2 NO" ;

label define H2080044X
         -1 "-1 INAPPLICABLE"
         1 "1 YES"
         2 "2 NO" ;

label define H2080045X
         -1 "-1 INAPPLICABLE"
         1 "1 YES"
         2 "2 NO" ;

label define H2080046X
         -1 "-1 INAPPLICABLE"
         1 "1 YES"
         2 "2 NO" ;

label define H2080047X
         -1 "-1 INAPPLICABLE"
         1 "1 YES"
         2 "2 NO" ;

label define H2080048X
         -1 "-1 INAPPLICABLE"
         1 "1 YES"
         2 "2 NO" ;

label define H2080049X
         -1 "-1 INAPPLICABLE"
         1 "1 YES"
         2 "2 NO" ;

label define H2080050X
         -1 "-1 INAPPLICABLE"
         1 "1 YES"
         2 "2 NO" ;

label define H2080051X
         -1 "-1 INAPPLICABLE"
         1 "1 YES"
         2 "2 NO" ;

label define H2080052X
         -1 "-1 INAPPLICABLE"
         1 "1 YES"
         2 "2 NO" ;

label define H2080053X
         -1 "-1 INAPPLICABLE"
         1 "1 YES"
         2 "2 NO" ;

label define H2080054X
         -1 "-1 INAPPLICABLE"
         1 "1 YES"
         2 "2 NO" ;

label define H2080055X
         -1 "-1 INAPPLICABLE"
         1 "1 YES"
         2 "2 NO" ;

label define H2080056X
         -1 "-1 INAPPLICABLE"
         1 "1 YES"
         2 "2 NO" ;

label define H2080057X
         -1 "-1 INAPPLICABLE"
         1 "1 YES"
         2 "2 NO" ;

label define H2080058X
         -1 "-1 INAPPLICABLE"
         1 "1 YES"
         2 "2 NO" ;

label define H2080059X
         -1 "-1 INAPPLICABLE"
         1 "1 YES, EXCHANGE COVERAGE"
         2 "2 NO, NOT EXCHANGE COVERAGE" ;

label define H2080060X
         -1 "-1 INAPPLICABLE"
         -15 "-15 CANNOT BE COMPUTED"
         -7 "-7 REFUSED"
         -8 "-8 DK"
         1 "1 YES"
         2 "2 NO" ;

label define H2080061X
         -1 "-1 INAPPLICABLE"
         -15 "-15 CANNOT BE COMPUTED"
         -7 "-7 REFUSED"
         -8 "-8 DK"
         1 "1 EMPLOYER"
         10 "10 SPOUSE PREVIOUS EMPLOYER"
         11 "11 SCHOOL"
         12 "12 UNKNOWN TYPE-OUTSIDE RU"
         13 "13 UNKNOWN TYPE-COLLECTED AT OTHER"
         2 "2 UNION"
         20 "20 HIGH RISK POOL"
         21 "21 STATE EXCHANGE NAME"
         3 "3 GROUP"
         5 "5 INSURANCE COMPANY-FROM AN AGENT"
         6 "6 INSURANCE COMPANY"
         7 "7 HMO"
         8 "8 PREVIOUS EMPLOYER" ;

label define H2080062X
         -1 "-1 INAPPLICABLE"
         -15 "-15 CANNOT BE COMPUTED"
         -7 "-7 REFUSED"
         -8 "-8 DK"
         1 "1 PRIVATE PLAN IS HMO"
         2 "2 PRIVATE PLAN IS NOT HMO" ;

label define H2080063X
         -1 "-1 INAPPLICABLE"
         -15 "-15 CANNOT BE COMPUTED"
         -7 "-7 REFUSED"
         -8 "-8 DK"
         1 "1 YES"
         2 "2 NO" ;

* ASSOCIATE VARIABLES WITH VALUE LABEL DEFINITIONS;
label value CMJINS H2080001X;
label value COBRA H2080002X;
label value COVROUT_M18 H2080003X;
label value COVTYPIN H2080004X;
label value DECPHLDR H2080005X;
label value DENTLINS H2080006X;
label value DEPNDNT H2080007X;
label value EMPLSTAT H2080008X;
label value EVALCOVR H2080009X;
label value FYFLG H2080010X;
label value HOSPINSX H2080011X;
label value HSAACCT H2080012X;
label value JOBSFILE H2080013X;
label value JOBSINFR H2080014X;
label value MSUPINSX H2080015X;
label value NAMECHNG H2080016X;
label value NOPUFLG H2080017X;
label value OOPELIG H2080018X;
label value OOPFLAG H2080019X;
label value OOPPREM H2080020X;
label value OOPPREMX H2080021X;
label value OOPX12X H2080022X;
label value OUTPHLDR H2080023X;
label value PANEL H2080024X;
label value PHLDRCHNG H2080025X;
label value PHOLDER H2080026X;
label value PITFLG H2080027X;
label value PLANMETL H2080028X;
label value PMEDINS H2080029X;
label value PREMLEVX H2080030X;
label value PREMSUBZ H2080031X;
label value PRIVCAT H2080032X;
label value PrivateCat H2080033X;
label value RN H2080034X;
label value STATUS1 H2080035X;
label value STATUS10 H2080036X;
label value STATUS11 H2080037X;
label value STATUS12 H2080038X;
label value STATUS13 H2080039X;
label value STATUS14 H2080040X;
label value STATUS15 H2080041X;
label value STATUS16 H2080042X;
label value STATUS17 H2080043X;
label value STATUS18 H2080044X;
label value STATUS19 H2080045X;
label value STATUS2 H2080046X;
label value STATUS20 H2080047X;
label value STATUS21 H2080048X;
label value STATUS22 H2080049X;
label value STATUS23 H2080050X;
label value STATUS24 H2080051X;
label value STATUS3 H2080052X;
label value STATUS4 H2080053X;
label value STATUS5 H2080054X;
label value STATUS6 H2080055X;
label value STATUS7 H2080056X;
label value STATUS8 H2080057X;
label value STATUS9 H2080058X;
label value STEXCH H2080059X;
label value STSHOP H2080060X;
label value TYPEFLAG H2080061X;
label value UPRHMO H2080062X;
label value VISIONIN H2080063X;

*DISPLAY A DESCRIPTION OF STATA FILE;
describe;

*LIST FIRST 20 OBSERVATIONS IN THE FILE;
list in 1/20;

save H208, replace;

#delimit cr

* data file is stored in H208.dta
* log  file is stored in H208.log

log close

/************************************************************************************************
 NOTES:                                                                                          
                                                                                                 
 1. This program has been tested on Stata Version 10 (for Windows).                              
                                                                                                 
 2. This program will create a permanent Stata dataset.  All additional analyses                 
    can be run using this dataset.  In addition to the dataset, this program creates             
    a log file named H208.LOG and a data file named H208.DTA.  If these files (H208.DTA and H208.LOG)
    already exist in the working directory, they will be replaced when this program is executed. 
                                                                                                 
 3. If the program ends prematurely, the log file will remain open.  Before running this         
    program again, the user should enter the following Stata command: log close                  
                                                                                                 
 4. The cd command assigns C:\MEPS\DATA as the working directory and location of the input       
    ASCII and output .DTA and .LOG files and can be modified by the user as necessary.           
                                                                                                 
 5. Stata commands end with a carriage return by default. The command                            
    #delimit ;                                                                                   
    temporarily changes the command ending delimiter from a carriage return to a semicolon.      
                                                                                                 
 6. The infix command assumes that the input variables are numeric unless the variable name      
    is prefaced by str.  For example, DUPERSID is the a string (or character) variable.          
                                                                                                 
************************************************************************************************/