-
Notifications
You must be signed in to change notification settings - Fork 3
/
dataout_pmt_eligible.ado
executable file
·66 lines (46 loc) · 2 KB
/
dataout_pmt_eligible.ado
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
program define dataout_pmt_eligible
// August 03, 2010
syntax , Label(string) Filename(string) q(integer) Cutoffs(numlist) [Separator(string) Append]
version 9.1
tempname fh
// make sure the label has something
if ("`label'" == "") {
local label " "
}
if ("`separator'" == "") {
local separator ","
}
if ("`append'"=="append") {
file open `fh' using `"`filename'"', w append all
// di "append to exisiting file"
}
else {
// di "create new file"
file open `fh' using `"`filename'"', w replace all
local quantileHeadings = ""
forv quantile = 1/`q' {
local quantileHeadings = "`quantileHeadings'Q`quantile'`separator'"
}
file write `fh' `"Geography Covered`separator'`separator'`separator'Fraction Covered`separator'Cutoff`separator'Leakage`separator'Undercoverage`separator'Targeting Accuracy`separator'Inclusion Error Rate`separator'Exclusion Error Rate`separator'Eligibility Compliance (accuracy)`separator'`quantileHeadings'"' _n
}
local percentofpop_covered = r(fraction_covered)
local lineout1 `""`label'"`separator'`separator'`separator'`percentofpop_covered'"'
// go through the return values and make the output string
// loop over all cutoffs
foreach cutoff of numlist `cutoffs' {
local leakage = r(leakage)
local undercoverage = r(undercoverage)
local targeting_accuracy = r(targeting_accuracy2)
local inclusion_error_rate = r(inclusion_error_rate)
local exclusion_error_rate = r(exclusion_error_rate)
local eligibility_compliance = r(elig_compliance)
local lineout `"`lineout1'`separator'`cutoff'`separator'`leakage'`separator'`undercoverage'`separator'`targeting_accuracy'`separator'`inclusion_error_rate'`separator'`exclusion_error_rate'`separator'`eligibility_compliance'"'
// loop over number of quantiles
forv quantile = 1/`q' {
local nextelement = r(coverage_cutoff_quantile`quantile')
local lineout `"`lineout'`separator'`nextelement'"'
}
file write `fh' `"`lineout'"' _n
}
file close `fh'
end program