MEPS HC-218: 2020 Jobs File

Appendix 1: Sample SAS Program

Appendix 2. Sample Stata Program


Convert SAS Datasets to .dat Files

Sample SAS Program

libname jobs18 "c:\mydata\jobs18";
libname jobs19 "c:\mydata\jobs19";
libname jobs20 "c:\mydata\jobs20";
proc export data=jobs18.jobs18 outfile= jobs18.dta;
run;
proc export data=jobs19.jobs19 outfile= jobs19.dta;
run;
proc export data=jobs20.jobs20 outfile= jobs20.dta;
run;

Sample Convert SAS Program Log

1 libname jobs18 "c:\mydata\jobs18";
NOTE: Libref JOBS18 was successfully assigned as follows:
Engine: V9
Physical Name: c:\mydata\jobs18
2 libname jobs19 "c:\mydata\jobs19";
NOTE: Libref JOBS19 was successfully assigned as follows:
Engine: V9
Physical Name: c:\mydata\jobs19
3 libname jobs20 "c:\mydata\jobs20";
NOTE: Libref JOBS20 was successfully assigned as follows:
Engine: V9
Physical Name: c:\mydata\jobs20
4
5 proc export data=jobs18.jobs18 outfile=
5 ! "c:\mydata\jobs18\jobs18.dta";
6 run;

NOTE: The export data set has 53323 observations and 85 variables.
NOTE: "c:\mydata\jobs18\jobs18.dta" file was successfully created.
NOTE: PROCEDURE EXPORT used (Total process time):
real time 3.71 seconds
cpu time 0.29 seconds

7
8 proc export data=jobs19.jobs19 outfile=
8 ! "c:\mydata\jobs19\jobs19.dta";
9 run;

NOTE: The export data set has 50334 observations and 84 variables.
NOTE: "c:\mydata\jobs19\jobs19.dta" file was successfully created.
NOTE: PROCEDURE EXPORT used (Total process time):
real time 3.01 seconds
cpu time 0.20 seconds

10
11 proc export data=jobs20.jobs20 outfile=
11 ! "c:\mydata\jobs20\jobs20.dta";
12 run;

NOTE: The export data set has 47776 observations and 84 variables.
NOTE: "c:\mydata\jobs20\jobs20.dta" file was successfully created.
NOTE: PROCEDURE EXPORT used (Total process time):
real time 2.96 seconds
cpu time 0.20 seconds

Sample Stata Program

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

*a. Select continuing Panel 23 Round 5 or Panel 24 Round 3
* Current Main JOBS (SUBTYPE=1, STILLAT=1) from the FY 2020 JOBS file
* and print selected variables from the first 20 observations

use "c:\mydata\jobs20.dta", clear
format PANEL SUBTYPE STILLAT SICKPAY %3.0f
keep if (PANEL==23 & RN==5 & ORIGRND < 5 & SUBTYPE==1 & STILLAT==1 & SICKPAY==-1) | (PANEL==24 & RN==3 & ORIGRND < 3 & SUBTYPE==1 & STILLAT==1 & SICKPAY==-1)

*Print Sample of Continuation P23 R5 and P24 R3 Current Main Job 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 P23 R5 or P24 R3 Records)
sort JOBIDX
save "c:\mydata\j20.dta", replace

*b. Select newly reported Panel 23 or Panel 24 Current Main JOBS
* records from the FY 2019 JOBS file and print selected variables
* from the first 20 observations.

use "c:\mydata\jobs19.dta", clear
format PANEL SUBTYPE STILLAT SICKPAY %3.0f
keep if ((PANEL==23 & (RN==3 | RN==4) ) | (PANEL==24 & (RN==1 | RN==2))) & SUBTYPE==1 & STILLAT==-1

*Print Sample of Newly Reported P23 R3 or 4 and P24 R1 or 2 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 P23 R3 or 4 and P24 R1 or 2 Records)
sort JOBIDX
rename SICKPAY SICKPAY19
keep JOBIDX SICKPAY19
save "c:\mydata\j19.dta", replace

*Sickpay Value of FY2019 P23 R3 or 4 and P24 R1 or 2 Newly Reported CMJs

asdoc tabulate SICKPAY19, font(arial) fs(8), save(stata_output.doc) title(Sickpay Value of FY2019 P23 R3 or 4 and P24 R 1 or 2 Newly Reported CMJs)

*c. Select newly reported Panel 23 Current Main JOBS records from
* the FY 2018 JOBS file and print selected variables from the
* first 20 observations.

use "c:\mydata\jobs18.dta", clear
format PANEL SUBTYPE STILLAT SICKPAY %3.0f
keep if PANEL==23 & (RN==1 | RN==2) & SUBTYPE==1 & STILLAT==-1

*Print Sample of Newly Reported P23 R1 or 2 Records

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

*Sickpay Value of FY2018 P23 R1 or 2 Newly Reported CMJs

sort JOBIDX
rename SICKPAY SICKPAY18
keep JOBIDX SICKPAY18
save "c:\mydata\j18.dta", replace
asdoc tabulate SICKPAY18, font(arial) fs(8), save(stata_output.doc) title(Sickpay Value of FY2018 P23 R1 or 2 Newly Reported CMJs)

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

use "c:\mydata\j20.dta", clear
merge 1:m JOBIDX using "c:\mydata\j19.dta", generate(matchvar19)
gen SICKPAYX = .
keep if matchvar19 == 1 | matchvar19 == 3
replace SICKPAYX = SICKPAY19 if SICKPAY19 != .
merge 1:m JOBIDX using "c:\mydata\j18.dta", generate(matchvar18)
keep if matchvar18 == 3 | matchvar19 == 3
replace SICKPAYX = SICKPAY18 if SICKPAY19 == .
save "c:\mydata\j20r53f.dta", replace

* Diagnostic Post-Merge - Sickpay * Sickpayx
* Continuation P23 R5 and P24 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 23 Round 5 or Panel 24 Round 3
. * Current Main JOBS (SUBTYPE=1, STILLAT=1) from the FY 2020 JOBS file
. * and print selected variables from the first 20 observations
.

.
. use "c:\mydata\jobs20.dta", clear
.
. format PANEL SUBTYPE STILLAT SICKPAY %3.0f
.
. keep if (PANEL==23 & RN==5 & ORIGRND < 5 & SUBTYPE==1 & STILLAT==1 & SICKPAY==-1) | (PANEL==24 & R
> N==3 & ORIGRND < 3 & SUBTYPE==1 & STILLAT==1 & SICKPAY==-1)
(40,397 observations deleted)

.
. *Print Sample of Continuation P23 R5 and P24 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 P23 R5 or P24 R3 Records)
(File stata_output.doc already exists, option append was assumed)
.
. sort JOBIDX
.
. save "c:\mydata\j20.dta", replace
file c:\mydata\j20.dta saved
.
.

.
.*b. Select newly reported Panel 23 or Panel 24 Current Main JOBS
.* records from the FY 2019 JOBS file and print selected variables
.* from the first 20 observations.
.

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

.
. format PANEL SUBTYPE STILLAT SICKPAY %3.0f

.
. keep if ((PANEL==23 & (RN==3 | RN==4) ) | (PANEL==24 & (RN==1 | RN==2))) & SUBTYPE==1 & STILLAT==-
> 1
(41,410 observations deleted)

.
.

. *Print Sample of Newly Reported P23 R3 or 4 and P24 R1 or 2 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 P23 R3 or 4 and P24 R1 or 2
> Records)
(File stata_output.doc already exists, option append was assumed)

.
. sort JOBIDX

.
. rename SICKPAY SICKPAY19

.
. keep JOBIDX SICKPAY19

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

.

. *Sickpay Value of FY2019 P23 R3 or 4 and P24 R1 or 2 Newly Reported CMJs
.

.
. asdoc tabulate SICKPAY19, font(arial) fs(8), save(stata_output.doc) title(Sickpay Value of FY2019
> P23 R3 or 4 and P24 R 1 or 2 Newly Reported CMJs)
(File stata_output.doc already exists, option append was assumed)

.
.

.*c. Select newly reported Panel 23 Current Main JOBS records from
.* the FY 2018 JOBS file and print selected variables from the
.* first 20 observations.

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

.
. format PANEL SUBTYPE STILLAT SICKPAY %3.0f

.
. keep if PANEL==23 & (RN==1 | RN==2) & SUBTYPE==1 & STILLAT==-1
(45,549 observations deleted)

.

. *Print Sample of Newly Reported P23 R1 or 2 Records

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

.

. *Sickpay Value of FY2018 P23 R1 or 2 Newly Reported CMJs

.
. sort JOBIDX

.
. rename SICKPAY SICKPAY18

.
. keep JOBIDX SICKPAY18

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

.
. asdoc tabulate SICKPAY18, font(arial) fs(8), save(stata_output.doc) title(Sickpay Value of FY2018
> P23 R1 or 2 Newly Reported CMJs)
(File stata_output.doc already exists, option append was assumed)

.
.

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

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

Result # of obs.

not matched 7,115
from master 2,785 (matchvar19==1)
from using 4,330 (matchvar19==2)
matched 4,594 (matchvar19==3)

.
. gen SICKPAYX = .
(11,709 missing values generated)

. keep if matchvar19 == 1 | matchvar19 == 3
(4,330 observations deleted)

. replace SICKPAYX = SICKPAY19 if SICKPAY19 != .
(4,594 real changes made)

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

Result # of obs.

not matched 9,583
from master 4,594 (matchvar18==1)
from using 4,989 (matchvar18==2)
matched 2,785 (matchvar18==3)

.
. keep if matchvar18 == 3 | matchvar19 == 3
(4,991 observations deleted)

. replace SICKPAYX = SICKPAY18 if SICKPAY19 == .
(2,783 real changes made)

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

.
.

. * Diagnostic Post-Merge - Sickpay * Sickpayx
. * Continuation P23 R5 and P24 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