-
Notifications
You must be signed in to change notification settings - Fork 6
/
make.do
312 lines (250 loc) · 9.07 KB
/
make.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
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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
// the 'make.do' file is automatically created by 'github' package.
// execute the code below to generate the package installation files.
// DO NOT FORGET to update the version of the package, if changed!
// for more information visit http://github.com/haghish/github
*##s
cap program drop getfiles
program define getfiles, rclass
args mask
local f2add: dir . files "`mask'", respectcase
foreach a of local f2add {
local as "`as' `a'"
}
local as = trim("`as'")
local as: subinstr local as " " ";", all
return local files = "`as'"
end
cd "c:/Users/`c(username)'/OneDrive - WBG/WorldBank/DECDG/PIP/pip"
getfiles "*.ado"
local as = "`r(files)'"
getfiles "*.sthlp"
local hs = "`r(files)'"
getfiles "*.mata"
local ms = "`r(files)'"
getfiles "*.dlg"
local ds = "`r(files)'"
getfiles "*.dta"
local dtas = "`r(files)'"
local toins "`as';`hs';`ms';`ds';`dtas'"
disp "`toins'"
make pip, replace toc pkg /// readme
version(0.10.10) ///
license("MIT") ///
author("R.Andres Castaneda") ///
affiliation("The World Bank") ///
email("[email protected]") ///
url("") ///
title("Poverty and Inequality Platform Stata wrapper") ///
description("World Bank PIP API Stata wrapper") ///
install("`toins'") ///
ancillary("")
*##e
* ------------------------------------------------------------------------------
* Testing basic examples
* ------------------------------------------------------------------------------
clear all
pip cleanup
global options = "server(qa) clear"
cap frame drop tmpfr
frame create tmpfr strL cmd
frame post tmpfr ("pip versions") // first command
frame post tmpfr ("pip, country(col arg) year(last) ${options}") // load latest available survey-year estimates for sampel countries
frame post tmpfr ("pip, info ${options}") // load clickable menu
frame post tmpfr ("pip, country(all) coverage(urban) ${options}") // load only urban coverage level
frame post tmpfr ("pip, country(COL BRA ARG IND) year(2015) ${options}") // country estimation at $1.9 in 2015. Since there are no surveys in ARG and IND in 2015, results are loaded for COL and BRA
frame post tmpfr ("pip, country(COL BRA ARG IND) year(2015) fillgaps ${options}") // filling gaps for ARG and IND. Only works for reference years
frame post tmpfr ("pip wb, year(2015) ${options}") // World Bank aggregation
frame post tmpfr ("pip wb, region(SAR LAC) ${options}")
frame post tmpfr ("pip wb, ${options}")
*frame post tmpfr ("pip cl, country(COL BRA ARG IND) year(2011) clear coverage('national national urban national') ${options}")
frame post tmpfr ("pip, region(EAP) year(all) ${options}")
frame post tmpfr ("pip tables, ${options}")
frame post tmpfr ("pip tables, table(countries) ${options}")
frame post tmpfr ("pip tables, table(country_coverage) ${options}")
frame post tmpfr ("pip tables, table(cpi) ${options}")
frame post tmpfr ("pip tables, table(decomposition) ${options}")
frame post tmpfr ("pip tables, table(dictionary) ${options}")
frame post tmpfr ("pip tables, table(framework) ${options}")
frame post tmpfr ("pip tables, table(gdp) ${options}")
frame post tmpfr ("pip tables, table(incgrp_coverage) ${options}")
frame post tmpfr ("pip tables, table(indicators) ${options}")
frame post tmpfr ("pip tables, table(interpolated_means) ${options}")
frame post tmpfr ("pip tables, table(pce) ${options}")
frame post tmpfr ("pip tables, table(pop) ${options}")
frame post tmpfr ("pip tables, table(pop_region) ${options}")
frame post tmpfr ("pip tables, table(poverty_lines) ${options}")
frame post tmpfr ("pip tables, table(ppp) ${options}")
frame post tmpfr ("pip tables, table(region_coverage) ${options}")
frame post tmpfr ("pip tables, table(regions) ${options}")
frame post tmpfr ("pip tables, table(survey_means) ${options}")
frame tmpfr {
global N = _N
}
forvalues i = 1/$N {
local cmd = _frval(tmpfr, cmd, `i')
cap `cmd'
if _rc noi disp "`cmd' - NOT WORKING"
}
*******************************************************************************
// Compare dev and prod versions
// Version
pip version
// setup dev options
global options = "server(qa)"
// Function to avoid errors and scale up check
cap program drop pip_prod_dev
program define pip_prod_dev
syntax , ///
cmd(string) ///
sorting_vars(string) ///
[ ///
test_label(string) ///
test_server(string) ///
main_server(string) ///
disp ///
* /// pip options
]
// Conditions
qui {
if ("`test_label'" == "") {
local test_label "Unknown"
}
if ("`test_server'" == "") {
local test_server "dev"
}
if ("`main_server'" == "") {
local main_server "prod"
}
// tests
pip `cmd' `options' server(`main_server')
duplicates report `sorting_vars'
cap assert r(unique_value)==r(N)
if _rc {
noi disp as err "Duplicate records in `test_label' (server `main_server') data"
exit
}
sort `sorting_vars'
tempfile main_data
save `main_data'
pip `cmd' `options' server(`test_server')
duplicates report `sorting_vars'
cap assert r(unique_value)==r(N)
if _rc {
noi disp as err "Duplicate records in `test_label' (server `test_server') data"
exit
}
sort `sorting_vars'
if ("`disp'" == "") {
cap cf _all using `main_data'
if _rc {
noi disp as err "`test_label' of `main_server' and `test_server' don't match"
noi disp "Display details " `"{stata `"pip_prod_dev `0' disp"':here}"'
}
}
else {
noi cf _all using `main_data', verbose all
}
}
end
// 1- compare country level estimates for ppp 2017
pip_prod_dev, ///
cmd(", povline(2.15 3.65 6.85) clear") ///
sorting_vars("country_code region_code year welfare_type poverty_line reporting_level") ///
test_label("Country estimate")
// 2- wb aggregate estimates for poverty line 2.15, 3.65, and 6.85
pip_prod_dev, ///
cmd("wb, povline(2.15 3.65 6.85) clear") ///
sorting_vars("region_name year poverty_line") ///
test_label("WB aggregate")
// 3- filling gap data for all countries
pip_prod_dev, ///
cmd(", fillgaps povline(2.15 3.65 6.85) clear") ///
sorting_vars("country_code region_code year welfare_type poverty_line reporting_level") ///
test_label("Fillgaps data")
*******************************************************************************
* auxilary tables
// 1) countries
pip_prod_dev, ///
cmd("tables, table(countries) clear") ///
sorting_vars("country_code") ///
test_label("Auxilary table - countries")
// 2) country coverage
pip_prod_dev, ///
cmd("tables, table(country_coverage) clear") ///
sorting_vars("country_code year pop_data_level") ///
test_label("Auxilary table - country_coverage")
// 3) cpi
pip_prod_dev, ///
cmd("tables, table(cpi) clear") ///
sorting_vars("country_code data_level") ///
test_label("Auxilary table - cpi")
// 4) decomposition
pip_prod_dev, ///
cmd("tables, table(decomposition) clear") ///
sorting_vars("variable_code variable_values") ///
test_label("Auxilary table - decomposition")
// 5) dictionary
pip_prod_dev, ///
cmd("tables, table(dictionary) clear") ///
sorting_vars("variable") ///
test_label("Auxilary table - dictionary")
// 6) framework
pip_prod_dev, ///
cmd("tables, table(framework) clear") ///
sorting_vars("country_code year survey_coverage welfare_type") ///
test_label("Auxilary table - framework")
// 7) gdp
pip_prod_dev, ///
cmd("tables, table(gdp) clear") ///
sorting_vars("country_code data_level") ///
test_label("Auxilary table - gdp")
// 8) incgrp_coverage
pip_prod_dev, ///
cmd("tables, table(incgrp_coverage) clear") ///
sorting_vars("year") ///
test_label("Auxilary table - incgrp_coverage")
// 9) indicators
pip_prod_dev, ///
cmd("tables, table(indicators) clear") ///
sorting_vars("indicator_code page") ///
test_label("Auxilary table - indicators")
// 10) interpolated_means
pip_prod_dev, ///
cmd("tables, table(interpolated_means) clear") ///
sorting_vars("survey_id interpolation_id") ///
test_label("Auxilary table - interpolated_means")
// 11) pce
pip_prod_dev, ///
cmd("tables, table(pce) clear") ///
sorting_vars("country_code data_level") ///
test_label("Auxilary table - pce")
// 12) pop
pip_prod_dev, ///
cmd("tables, table(pop) clear") ///
sorting_vars("country_code data_level") ///
test_label("Auxilary table - pop")
// 13) pop_region
pip_prod_dev, ///
cmd("tables, table(pop_region) clear") ///
sorting_vars("region_code year") ///
test_label("Auxilary table - pop_region")
// 14) poverty_lines
pip_prod_dev, ///
cmd("tables, table(poverty_lines) clear") ///
sorting_vars("name") ///
test_label("Auxilary table - poverty_lines")
// 15) ppp
pip_prod_dev, ///
cmd("tables, table(ppp) clear") ///
sorting_vars("country_code data_level") ///
test_label("Auxilary table - ppp")
// 16) regions
pip_prod_dev, ///
cmd("tables, table(regions) clear") ///
sorting_vars("region_code") ///
test_label("Auxilary table - regions")
// 17) regions_coverage
pip_prod_dev, ///
cmd("tables, table(region_coverage) clear") ///
sorting_vars("year pcn_region_code") ///
test_label("Auxilary table - regions_coverage")