-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy pathEx1_shell.do
90 lines (43 loc) · 1.96 KB
/
Ex1_shell.do
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
************************************************************************************************************************************
* Exercise 1:
* This program generates the following estimates on national health care for the U.S. civilian non-institutionalized population, 2021:
* - Overall expenses (National totals)
* - Percentage of persons with an expense
* - Mean expense per person
* - Mean/median expense per person with an expense:
* - Mean expense per person with an expense
* - Mean expense per person with an expense, by age group
* - Median expense per person with an expense, by age group
*
* Input file:
* - C:/MEPS/h233.dta (2021 Full-year file)
*
* This program is available at:
* https://github.com/HHS-AHRQ/MEPS-workshop/tree/master/stata_exercises
************************************************************************************************************************************
clear
set more off
capture log close
cd C:\MEPS
log using Ex1.log, replace
/* Get data from web (you can also download manually) */
copy "https://meps.ahrq.gov/mepsweb/data_files/pufs/h233/h233dta.zip" "h233dta.zip", replace
unzipfile "h233dta.zip", replace
/* Read in 2021 Full-year consolidated file */
/* define expenditure variables (transformations, etc.) */
/* create age categorical variable */
// here's an alternative way to create a categorical variable
*egen agecat2=cut(agelast), at(0 65 100)
// create and assign value labels to age
/* QC check new variables*/
/* identify the survey design characteristics */
/* total expenses */
// list output stored in r()
// display results without scientific notation
/* percent of people with any expense */
/* mean expense per person */
/* mean expense per person with an expense */
/* mean expense per person with an expense, by age */
/* median expense per person with an expense, by age */
// alternative way
*table agecat [pw=perwt] if total_exp>0, stat(median total_exp)