-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy pathexercise2.sas
134 lines (94 loc) · 4.59 KB
/
exercise2.sas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
/******************************************************************************************
This program pools 2019, 2020, and 2021 MEPS FYC files and calculates annual averages for:
- proportion of people diagnosed with bladder cancer
- average expenditures and average amount paid out of pocket per person by bladder cancer diagnosis status
- standard errors for annual averages
Input files:
- C:\MEPS\h216.sas7bdat (2019 Full-Year Consolidated (FYC) file)
- C:\MEPS\h224.sas7bdat (2020 Full-Year Consolidated (FYC) file)
- C:\MEPS\h233.sas7bdat (2021 Full-Year Consolidated (FYC) file)
!!Note: When pooling data years before and after 2002 or 2019, the Pooled Linkage File (h36u22) must be used for correct
variance estimation. The name of the Pooled Linkage File changes with each new year of data (e.g. 'h36u23' once 2023
data is added). The Pooled Linkage File is NOT needed for this example because all data years are 2019 and after.
The pooled linkage file and documentation is available here:
https://meps.ahrq.gov/mepsweb/data_stats/download_data_files_detail.jsp?cboPufNumber=HC-036
**********************************************************************/
/* Set libname for folder with MEPS data */
libname meps "C:/MEPS";
/********** Read in data files **********/
/* Read in 2019, 2020, and 2021 FYC data files, rename year-specific variables to common names across years,
create year variable, and keep only needed variables */
/* 2019 */
data fyc19;
set meps.h216;
year = 2019;
totexp = totexp19;
totslf = totslf19;
perwt = perwt19f;
keep year dupersid panel cancerdx cabladdr totexp totslf perwt varstr varpsu;
run;
/* 2020 */
data fyc20;
set meps.h224;
year = 2020;
totexp = totexp20;
totslf = totslf20;
perwt = perwt20f;
keep year dupersid panel cancerdx cabladdr totexp totslf perwt varstr varpsu;
run;
/* 2021 */
data fyc21;
set meps.h233;
year = 2021;
totexp = totexp21;
totslf = totslf21;
perwt = perwt21f;
keep year dupersid panel cancerdx cabladdr totexp totslf perwt varstr varpsu;
run;
/********** Prepare the data **********/
/* Look at the variable cabladdr and cancerdx for one year to understand skip pattern */
/* From the documentation:
- Questions about cancer were asked only of persons aged 18 or older
- CANCERDX asks whether person was ever diagnosed with cancer
- Only if YES to CANCERDX, then asked what type (CABLADDR, CABLOOD, CABREAST...) */
proc freq data=fyc21;
tables cabladdr*cancerdx / missing;
run;
/* Concatenate (stack) 2019, 2020, and 2021 full year consolidated files, create pooled weight, and create variable
for bladder cancer diagnosis */
data meps_pooled;
set fyc19 fyc20 fyc21;
/* Create pooled weight by dividing by the number of years being pooled.
This will produce an annual average across the number of years being pooled as your estimate. */
poolwt = perwt/3;
/* Create a new variable: bladder_cancer */
if cabladdr = 1 then bladder_cancer = 1; /* has bladder cancer */
else if cabladdr = 2 or cancerdx = 2 then bladder_cancer = 0; /* need to check both CABLADDR *AND* CANCERDX for no*/
else if cabladdr < 0 then bladder_cancer = .; /* negative codes in MEPS are for missing and inapplicable */
run;
/* QC construction of variables */
proc freq data=meps_pooled;
tables bladder_cancer bladder_cancer*cancerdx / missing;
run;
/********** Estimation **********/
/* Suppress the graphics for easier viewing */
ods graphics off;
/* Proportion of people diagnosed with bladder cancer - ANNUAL AVERAGE from 2019-2021 */
title 'Proportion of people diagnosed with bladder cancer, 2019-2021 annual average';
proc surveymeans data=meps_pooled nobs mean;
stratum varstr; /* stratum from FYCs*/
cluster varpsu; /* PSU from FYCs */
weight poolwt; /* pooled weight we created */
var bladder_cancer; /* 1/0 variable for whether person has bladder cancer */
run;
/* Average expenditures and out of pocket payments per person by bladder cancer status,
ANNUAL AVERAGES from 2019-2021 */
title 'Average expenditures and out of pocket per person with and without bladder cancer, 2019-2021 annual average';
proc surveymeans data=meps_pooled nobs mean;
stratum varstr; /* stratum from FYCs */
cluster varpsu; /* PSU from FYCs */
weight poolwt; /* pooled weight we created */
var totexp totslf; /* total expenditures and OOP expenditures */
domain bladder_cancer; /* subpops are people who have and don't have bladder cancer */
run;
title; /* cancel the TITLE statements */