MEPS HC-237: 2022 Jobs File

Appendix 1: Sample SAS Program

Appendix 2. Sample Stata Program


Convert SAS Datasets to .dat Files

libname jobs19 "c:\mydata\jobs19";
libname jobs20 "c:\mydata\jobs20";
libname jobs21 "c:\mydata\jobs21";
libname jobs22 "c:\mydata\jobs22";

proc export data=jobs19.jobs18 outfile= jobs19.dta;
run;

proc export data=jobs20.jobs19 outfile= jobs20.dta;
run;

proc export data=jobs21.jobs20 outfile= jobs21.dta;
run;

proc export data=jobs22.jobs21 outfile= jobs22.dta;
run;

Obtain ASDOC Program

The STATA program ASDOC generates a log file and is called in the STATA program provided below. Users should download the program by entering STATA and keying the following into STATA command line:

ssc install asdoc, replace

Sample Stata Program

*#delimit ;
set linesize 100
log using "c:\mydata\APPdofile.log", replace

* a. Select continuing Panel 24 Round 7 or Panel 26 Round 3 Current Main Jobs
*(SUBTYPE=1, STILLAT=1) from the FY 2022 JOBS file and print selected variables from first 20 obs

use "c:\mydata\jobs22.dta", clear

format PANEL OrigRnd SUBTYPE STILLAT SICKPAY %3.0f

keep if (PANEL==24 & RN==7 & OrigRnd < 7 & SUBTYPE==1 & STILLAT==1 & SICKPAY==-1) | (PANEL==26 & RN==3 & OrigRnd < 3 & SUBTYPE==1 & STILLAT==1 & SICKPAY==-1)

*Print Sample of Continuation P24 R7 and P26 R3 Records

asdoc list JOBIDX PANEL RN OrigRnd SUBTYPE STILLAT SICKPAY if _n<=20, font(arial) fs(8) separator(0) noobs, save(stata_output.doc) title(Print Sample of Continuation P24 R7 or P26 R3 Records)

sort JOBIDX

save "c:\mydata\j22.dta", replace

* b. Select newly reported Panel 24 or Panel 26 Current Main Jobs
* records from the FY 2021 JOBS file and print selected variables from first 20 obs

use "c:\mydata\jobs21.dta", clear

format PANEL OrigRnd SUBTYPE STILLAT SICKPAY %3.0f

keep if ((PANEL==24 & (RN==5 | RN==6) ) | (PANEL==26 & (RN==1 | RN==2))) & SUBTYPE==1 & STILLAT==-1

*Print Sample of Newly Reported P24 R5 or R6 and P26 R1 or R2 Records

asdoc list JOBIDX PANEL RN OrigRnd SUBTYPE STILLAT SICKPAY if _n<=20, font(arial) fs(8) separator(0) noobs, save(stata_output.doc) title(Print Sample of Newly Reported P24 R5 or R6 and P26 R1 or R2 Records)

sort JOBIDX

rename SICKPAY SICKPAY21

keep JOBIDX SICKPAY21

save "c:\mydata\j21.dta", replace

*Sickpay Value of FY2021 P24 R5 or R6 and P26 R1 or R2 Newly Reported CMJs

asdoc tabulate SICKPAY21, font(arial) fs(8), save(stata_output.doc) title(Sickpay Value of FY2021 P24 R5 or R6 and P26 R1 or R2 Newly Reported CMJs)

* c. Select newly reported Panel 24 Current Main Jobs records from
* the FY 2020 JOBS file and print selected variables from first 20 obs

use "c:\mydata\jobs20.dta", clear

format PANEL OrigRnd SUBTYPE STILLAT SICKPAY %3.0f

keep if PANEL==24 & (RN==3 | RN==4) & SUBTYPE==1 & STILLAT==-1

*Print Sample of Newly Reported P24 R3 or 4 Records

asdoc list JOBIDX PANEL RN OrigRnd SUBTYPE STILLAT SICKPAY if _n<=20, font(arial) fs(8) separator(0) noobs, save(stata_output.doc) title(Print Sample of Newly Reported P24 R3 or R4 Records)

sort JOBIDX

rename SICKPAY SICKPAY20

keep JOBIDX SICKPAY20

save "c:\mydata\j20.dta", replace

*Sickpay Value of FY2020 P24 R3 or R4 Newly Reported CMJs

asdoc tabulate SICKPAY20, font(arial) fs(8), save(stata_output.doc) title(Sickpay Value of FY2020 P24 R3 or R4 Newly Reported CMJs)

* d. Select newly reported Panel 24 Current Main Jobs records from
* the FY 2019 JOBS file and print selected variables from first 20 obs

use "c:\mydata\jobs19.dta", clear

format PANEL OrigRnd SUBTYPE STILLAT SICKPAY %3.0f

keep if PANEL==24 & (RN==1 | RN==2) & SUBTYPE==1 & STILLAT==-1

*Print Sample of Newly Reported P24 R1 or R2 Records

asdoc list JOBIDX PANEL RN OrigRnd SUBTYPE STILLAT SICKPAY if _n<=20, font(arial) fs(8) separator(0) noobs, save(stata_output.doc) title(Print Sample of Newly Reported P24 R1 or R2 Records)

*Sickpay Value of FY2019 P24 R1 or R2 Newly Reported CMJs

sort JOBIDX

rename SICKPAY SICKPAY19

keep JOBIDX SICKPAY19

save "c:\mydata\j19.dta", replace

asdoc tabulate SICKPAY19, font(arial) fs(8), save(stata_output.doc) title(Sickpay Value of FY2019 P24 R1 or R2 Newly Reported CMJs)

* e. Create a dataset (J22R73F) that includes all variables for the
* continuation Panel 24 Round 7 or Panel 26 Round 3
* Current Main Jobs and create the new variable SICKPAYX by copying
* SICKPAY from the corresponding Round 1, Round 2, Round 3, Round 4,
* Round 5 or Round 6 newly reported job record.

use "c:\mydata\j22.dta", clear

merge 1:m JOBIDX using "c:\mydata\j21.dta", generate(matchvar21)

gen SICKPAYX = .
keep if matchvar21 == 1 | matchvar21 == 3
replace SICKPAYX = SICKPAY21 if SICKPAY21 != .

merge 1:m JOBIDX using "c:\mydata\j20.dta", generate(matchvar20)

keep if matchvar20 == 3 | matchvar21 == 1 | matchvar21 == 3
replace SICKPAYX = SICKPAY20 if SICKPAY20 != . & SICKPAY21 == .

merge 1:m JOBIDX using "c:\mydata\j19.dta", generate(matchvar19)

keep if matchvar19 == 3 | matchvar20 == 3 | matchvar21 == 3
replace SICKPAYX = SICKPAY19 if SICKPAY19 != . & SICKPAY20 == . & SICKPAY21 == .

save "c:\mydata\j22r73f.dta", replace

* Diagnostic Post-Merge - Sickpay * Sickpayx
* Continuation P24 R7 and P26 R3 Current Main Jobs Only

asdoc tabulate SICKPAY SICKPAYX, save(stata_output.doc) font(arial) fs(8) title(Diagnostic Post-Merge - Sickpay * Sickpayx)

log close

name: <unnamed>

log: c:\mydata\APPdofile.log

log type: text

.

. * a. Select continuing Panel 24 Round 7 or Panel 26 Round 3 Current Main Jobs
. *(SUBTYPE=1, STILLAT=1) from the FY 2022 JOBS file and print selected variables from first 20 obs

.

. use "c:\mydata\jobs22.dta", clear

.

. format PANEL OrigRnd SUBTYPE STILLAT SICKPAY %3.0f

.

. keep if (PANEL==24 & RN==7 & OrigRnd < 7 & SUBTYPE==1 & STILLAT==1 & SICKPAY==-1) | (PANEL==26 & R
> N==3 & OrigRnd < 3 & SUBTYPE==1 & STILLAT==1 & SICKPAY==-1)
(35,371 observations deleted)

.

. *Print Sample of Continuation P24 R7 and P26 R3 Records

.

. asdoc list JOBIDX PANEL RN OrigRnd SUBTYPE STILLAT SICKPAY if _n<=20, font(arial) fs(8) separator(
> 0) noobs, save(stata_output.doc) title(Print Sample of Continuation P24 R7 or P26 R3 Records)
(File stata_output.doc already exists, option append was assumed)

.

. sort JOBIDX

.

. save "c:\mydata\j22.dta", replace
file c:\mydata\j22.dta saved

.

.

. * b. Select newly reported Panel 24 or Panel 26 Current Main Jobs
. * records from the FY 2021 JOBS file and print selected variables from first 20 obs

.

. use "c:\mydata\jobs21.dta", clear

.

. format PANEL OrigRnd SUBTYPE STILLAT SICKPAY %3.0f

.

. keep if ((PANEL==24 & (RN==5 | RN==6) ) | (PANEL==26 & (RN==1 | RN==2))) & SUBTYPE==1 & STILLAT==-
> 1
(43,218 observations deleted)

.

. *Print Sample of Newly Reported P24 R5 or R6 and P26 R1 or R2 Records

.

. asdoc list JOBIDX PANEL RN OrigRnd SUBTYPE STILLAT SICKPAY if _n<=20, font(arial) fs(8) separator(
> 0) noobs, save(stata_output.doc) title(Print Sample of Newly Reported P24 R5 or R6 and P26 R1 or R
> 2 Records)
(File stata_output.doc already exists, option append was assumed)

.

. sort JOBIDX

.

. rename SICKPAY SICKPAY21

.

. keep JOBIDX SICKPAY21

.

. save "c:\mydata\j21.dta", replace
file c:\mydata\j21.dta saved

.

. *Sickpay Value of FY2021 P24 R5 or R6 and P26 R1 or R2 Newly Reported CMJs

.

. asdoc tabulate SICKPAY21, font(arial) fs(8), save(stata_output.doc) title(Sickpay Value of FY2021
> P24 R5 or R6 and P26 R1 or R2 Newly Reported CMJs)
(File stata_output.doc already exists, option append was assumed)

.

.

. * c. Select newly reported Panel 24 Current Main Jobs records from
. * the FY 2020 JOBS file and print selected variables from first 20 obs

.

. use "c:\mydata\jobs20.dta", clear

.

. format PANEL OrigRnd SUBTYPE STILLAT SICKPAY %3.0f

.

. keep if PANEL==24 & (RN==3 | RN==4) & SUBTYPE==1 & STILLAT==-1
(46,562 observations deleted)

.

. *Print Sample of Newly Reported P24 R3 or 4 Records

.

. asdoc list JOBIDX PANEL RN OrigRnd SUBTYPE STILLAT SICKPAY if _n<=20, font(arial) fs(8) separator(
> 0) noobs, save(stata_output.doc) title(Print Sample of Newly Reported P24 R3 or R4 Records)
(File stata_output.doc already exists, option append was assumed)

.

. sort JOBIDX

.

. rename SICKPAY SICKPAY20

.

. keep JOBIDX SICKPAY20

.

. save "c:\mydata\j20.dta", replace
file c:\mydata\j20.dta saved

.

. *Sickpay Value of FY2020 P24 R3 or R4 Newly Reported CMJs

.

. asdoc tabulate SICKPAY20, font(arial) fs(8), save(stata_output.doc) title(Sickpay Value of FY2020
> P24 R3 or R4 Newly Reported CMJs)
(File stata_output.doc already exists, option append was assumed)

.

.

. * d. Select newly reported Panel 24 Current Main Jobs records from
. * the FY 2019 JOBS file and print selected variables from first 20 obs

.

. use "c:\mydata\jobs19.dta", clear

.

. format PANEL OrigRnd SUBTYPE STILLAT SICKPAY %3.0f

.

. keep if PANEL==24 & (RN==1 | RN==2) & SUBTYPE==1 & STILLAT==-1
(43,233 observations deleted)

.

. *Print Sample of Newly Reported P24 R1 or R2 Records

.

. asdoc list JOBIDX PANEL RN OrigRnd SUBTYPE STILLAT SICKPAY if _n<=20, font(arial) fs(8) separator(
> 0) noobs, save(stata_output.doc) title(Print Sample of Newly Reported P24 R1 or R2 Records)
(File stata_output.doc already exists, option append was assumed)

.

. *Sickpay Value of FY2019 P24 R1 or R2 Newly Reported CMJs

.

. sort JOBIDX

.

. rename SICKPAY SICKPAY19

.

. keep JOBIDX SICKPAY19

.

. save " c:\mydata\j19.dta", replace
file c:\mydata\j19.dta saved

.

. asdoc tabulate SICKPAY19, font(arial) fs(8), save(stata_output.doc) title(Sickpay Value of FY2019
> P24 R1 or R2 Newly Reported CMJs)
(File stata_output.doc already exists, option append was assumed)

.

. * e. Create a dataset (J22R73F) that includes all variables for the
. * continuation Panel 24 Round 7 or Panel 26 Round 3
. * Current Main Jobs and create the new variable SICKPAYX by copying
. * SICKPAY from the corresponding Round 1, Round 2, Round 3, Round 4,
. * Round 5 or Round 6 newly reported job record.

.

. use "c:\mydata\j22.dta", clear

.

. merge 1:m JOBIDX using "c:\mydata\j21.dta", generate(matchvar21)

Result Number of obs

Not matched 3,656
from master 1,612 (matchvar21==1)
from using 2,044 (matchvar21==2)
Matched 3,091 (matchvar21==3)

.

. gen SICKPAYX = .
(6,747 missing values generated)

. keep if matchvar21 == 1 | matchvar21 == 3
(2,044 observations deleted)

. replace SICKPAYX = SICKPAY21 if SICKPAY21 != .
(3,091 real changes made)

.

.

. merge 1:m JOBIDX using "c:\mydata\j20.dta", generate(matchvar20)

Result Number of obs

Not matched 5,425
from master 4,457 (matchvar20==1)
from using 968 (matchvar20==2)
Matched 246 (matchvar20==3)

.

. keep if matchvar20 == 3 | matchvar21 == 1 | matchvar21 == 3

(968 observations deleted)

. replace SICKPAYX = SICKPAY20 if SICKPAY20 != . & SICKPAY21 == .
(244 real changes made)

.

.

. merge 1:m JOBIDX using "c:\mydata\j19.dta", generate(matchvar19)

Result Number of obs

Not matched 9,062
from master 3,332 (matchvar19==1)
from using 5,730 (matchvar19==2)
Matched 1,371 (matchvar19==3)

.

. keep if matchvar19 == 3 | matchvar20 == 3 | matchvar21 == 3
(5,732 observations deleted)

. replace SICKPAYX = SICKPAY19 if SICKPAY19 != . & SICKPAY20 == . & SICKPAY21 == .
(1,366 real changes made)

.

. save "c:\mydata\j22r73f.dta", replace
file c:\mydata\j22r73f.dta saved

.

.

. * Diagnostic Post-Merge - Sickpay * Sickpayx
. * Continuation P24 R7 and P26 R3 Current Main Jobs Only

.

. asdoc tabulate SICKPAY SICKPAYX, save(stata_output.doc) font(arial) fs(8) title(Diagnostic Post-Me
> rge - Sickpay * Sickpayx)
(File stata_output.doc already exists, option append was assumed)

.

. log close

name: <unnamed>
log: c:\mydata\APPdofile.log
log type: text


Return To Top