-
Notifications
You must be signed in to change notification settings - Fork 0
/
Section_D.do
697 lines (537 loc) · 17.6 KB
/
Section_D.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
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
/// Project: FICP_Survey_Project -- Section D
///-----------------------------------------------------------------------------
///-----------------------------------------------------------------------------
/// Program Setup
///-----------------------------------------------------------------------------
version 16 // Set Version number for backward compatibility
set more off // Disable partitioned output
clear all // Start with a clean slate
set linesize 80 // Line size limit to make output more readable
macro drop _all // Clear all macros
capture log close // Close existing log files
///-----------------------------------------------------------------------------
///-----------------------------------------------------------------------------
/* RUNS THE FOLLOWING:
0. Import files and HFC file set-up
1. Checks skip logic and missing values by section
2. Cleaning variables by section
//Finds long variable include
//Saves original variables order
//General cleaning
3. Label variables
4. Order variables in original sequence and saves dta
*/
///-----------------------------------------------------------------------------
//Set directory
include "Global_macro_A.do"
else {
global base "D:/Documents/Consultorias/World_Bank/FICP_Survey_Project"
cd "$base"
global data "D:/Documents/Consultorias/World_Bank/FICP_Survey_Project/Data/Database `dir'"
global output "D:/Documents/Consultorias/World_Bank/FICP_Survey_Project/OUTPUT"
}
//Install required packages
//ssc install listtab
/////////////////////////////////////////////////////////////
//// 0. Import files and HFC file set-up ////
////////////////////////////////////////////////////////////
use "$data/d_legal_regulatory_and_superviso-survey", clear
merge 1:1 country_code year status using "$data/b_financial_sector_landscape_-survey.dta"
keep if status == "Submitted to Review" // 143 observations deleted
keep if year == 2022 // 0 observations deleted
drop _merge
merge 1:1 country_code using "$base/WB_CountryClassification.dta"
keep if year == 2022 // 173 observations deleted
//assert c(N) == 91
//Create output files and setting charinclude
global filename "FICP_survey_Section_D_HFC_" // Change accordinly
global filedate : di %tdCCYY.NN.DD date(c(current_date), "DMY") // date of the report
local hfc_file "$base/Data/$filename$filedate.csv"
export excel using "$base/Data/$filename$filedate.csv", replace
foreach var of varlist _all {
//di `"`: var label `var''"'
char `var'[charname] "`var'"
}
/////////////////////////////////////////////////////////////
//// 1. Checks skip logic and missing values by section ////
////////////////////////////////////////////////////////////
///D. Legal, Regulatory and Supervisory Framework for Relevant Financial Service Providers
//Comment: All section D is conditional con b1_1/6!
//Check duplicate IDs
sort region country_code
capture drop id_dup
duplicates tag country_code, generate(id_dup) // Sort and Check for unique identifiers
if _rc != 0 di "observations by country are NOT unique in country_code"
else if _rc == 0 di "Observations by country are unique in this section"
listtab $id_info using `hfc_file' if id_dup == 1, delimiter(",") replace headlines(" ,Duplicate Country ID") headchars(charname)
sort region country_code
///D1. Please specify what authorities (if any) have a clear legal mandate for and are in charge of: i) issuing the following types of regulation for financial service providers, and ii) licensing, supervising, monitoring, and enforcing compliance with such regulation. Enter the name of the authority (or authorities).
#delimit ;
local var_1 d1_1_1
d1_1_2
d1_1_3
d1_1_4
d1_1_5
d1_1_6
d1_2_1
d1_2_2
d1_2_3
d1_2_4
d1_2_5
d1_2_6
d1_3_1
d1_3_2
d1_3_3
d1_3_4
d1_3_5
d1_3_6
d1_4_1
d1_4_2
d1_4_3
d1_4_4
d1_4_5
d1_4_6
d1_5_1
d1_5_2
d1_5_3
d1_5_4
d1_5_5
d1_5_6;
#delimit cr
#delimit ;
local var_2 b1_1
b1_1
b1_2
b1_2
b1_3
b1_3
b1_1
b1_1
b1_2
b1_2
b1_3
b1_3
b1_1
b1_1
b1_2
b1_2
b1_3
b1_3
b1_1
b1_1
b1_2
b1_2
b1_3
b1_3
b1_1
b1_1
b1_2
b1_2
b1_3
b1_3;
#delimit cr
local n : word count `var_2'
//Consitency checks of d1_1/5_1/6, only IF Commercial banks, Other banks and Financial cooperatives are regulated (B1_1/3==Yes)
capture drop consischeck
gen consischeck = 0
forvalues i = 1/`n' {
local a : word `i' of `var_1'
local b : word `i' of `var_2'
dis "`a'" "`b'"
replace consischeck = 1 if ((`a'== "NA" & `b' == "Yes")| (`a' == "N/A" & `b' == "Yes")|(`a' == "" & `b' == "Yes"))
//replace `a' = "NA" if consischeck == 1
}
listtab $id_info `var_1' consischeck `var_2' if consischeck == 1, delimiter(",") appendto(`hfc_file') replace headlines(" ,Consitency check of D1 variables: Answer only if Commercial banks, Other banks and Financial cooperatives are regulated") headchars(charname)
#delimit ;
local var_1 d1_2_1_1
d1_2_1_2
d1_2_1_3
d1_2_1_4
d1_2_1_5
d1_2_1_6
d1_2_2_1
d1_2_2_2
d1_2_2_3
d1_2_2_4
d1_2_2_5
d1_2_2_6
d1_2_3_1
d1_2_3_2
d1_2_3_3
d1_2_3_4
d1_2_3_5
d1_2_3_6
d1_2_4_1
d1_2_4_2
d1_2_4_3
d1_2_4_4
d1_2_4_5
d1_2_4_6
d1_2_5_1
d1_2_5_2
d1_2_5_3
d1_2_5_4
d1_2_5_5
d1_2_5_6;
#delimit cr
#delimit ;
local var_2 b1_4
b1_4
b1_5
b1_5
b1_6
b1_6
b1_4
b1_4
b1_5
b1_5
b1_6
b1_6
b1_4
b1_4
b1_5
b1_5
b1_6
b1_6
b1_4
b1_4
b1_5
b1_5
b1_6
b1_6
b1_4
b1_4
b1_5
b1_5
b1_6
b1_6;
#delimit cr
local n : word count `var_2'
//Consitency checks of d1_2_1/5_1/6, only IF ODTIs, CCPs and NB-EMIs are regulated (B1_4/6==Yes)
capture drop consischeck
gen consischeck = 0
forvalues i = 1/`n' {
local a : word `i' of `var_1'
local b : word `i' of `var_2'
dis "`a'" "`b'"
replace consischeck = 1 if ((`a'== "NA" & `b' == "Yes")| (`a' == "N/A" & `b' == "Yes")|(`a' == "" & `b' == "Yes"))
//replace `a' = "NA" if consischeck == 1
}
listtab $id_info `var_1' consischeck `var_2' if consischeck == 1, delimiter(",") appendto(`hfc_file') replace headlines(" ,Consitency check of D1 variables: Answer only if DTIs, CCPs and NB-EMIs are regulated") headchars(charname)
///D2.1. Are "commercial banks" permitted to carry out the following activities?
#delimit ;
local var_1 d2_1_a_1
d2_1_b_1
d2_1_c_1
d2_1_d_1
d2_1_e_1
d2_1_f_1
d2_1_g_1
d2_1_h_1
d2_1_i_1
d2_1_j_1
d2_1_k_1;
#delimit cr
//Missing values, conditional on having regulated commercial banks
capture drop mcheck
gen mcheck = 0
foreach i of local var_1 {
replace mcheck = 1 if missing(`i') & b1_1 == "No"
}
//Cleaning
foreach i of local var_1 {
replace `i' = "NA" if b1_1 == "No"| b1_1 == "NA"
}
listtab $id_info `var_1' mcheck b1_1 if mcheck == 1, delimiter(",") appendto(`hfc_file') replace headlines(" ,Missing values in D2.1, on having regulated commercial banks") headchars(charname)
//Comment: Is an explanation necesary if d2_1_a/k_1== Yes?
///D2.2 Are "other banks" permitted to carry out the following activities?
#delimit ;
local var_1 d2_2_a_1
d2_2_b_1
d2_2_c_1
d2_2_d_1
d2_2_e_1
d2_2_f_1
d2_2_g_1
d2_2_h_1
d2_2_i_1
d2_2_j_1
d2_2_k_1;
#delimit cr
//Missing values, conditional on having regulated other banks
capture drop mcheck
gen mcheck = 0
foreach i of local var_1 {
replace mcheck = 1 if missing(`i') & b1_2 == "Yes"
}
//Cleaning
foreach i of local var_1 {
replace `i' = "NA" if b1_2 == "No"| b1_2 == "NA"
}
listtab $id_info `var_1' mcheck b1_2 if mcheck == 1, delimiter(",") appendto(`hfc_file') replace headlines(" ,Missing values in D2.2, on having regulated other banks") headchars(charname)
//Comment: Is an explanation necesary if d2_2_a/k_1== Yes?
///D2.3 Are “financial cooperatives” permitted to carry out the following activities?
#delimit ;
local var_1 d2_3_a_1
d2_3_b_1
d2_3_c_1
d2_3_d_1
d2_3_e_1
d2_3_f_1
d2_3_g_1
d2_3_h_1
d2_3_i_1
d2_3_j_1
d2_3_k_1;
#delimit cr
//Missing values, conditional on having regulated financial cooperatives
capture drop mcheck
gen mcheck = 0
foreach i of local var_1 {
replace mcheck = 1 if missing(`i') & b1_3 == "Yes"
}
//Cleaning
foreach i of local var_1 {
replace `i' = "NA" if b1_3 == "No"| b1_3 == "NA"
}
listtab $id_info `var_1' mcheck b1_3 if mcheck == 1, delimiter(",") appendto(`hfc_file') replace headlines(" ,Missing values in D2.3, on having regulated financial cooperatives") headchars(charname)
//Comment: Is an explanation necesary if d2_3_a/k_1== Yes?
///D2.4 Are “ODTIs” permitted to carry out the following activities?
#delimit ;
local var_1 d2_4_a_1
d2_4_b_1
d2_4_c_1
d2_4_d_1
d2_4_e_1
d2_4_f_1
d2_4_g_1
d2_4_h_1
d2_4_i_1
d2_4_j_1
d2_4_k_1;
#delimit cr
//Missing values, conditional on having regulated ODTIs
capture drop mcheck
gen mcheck = 0
foreach i of local var_1 {
replace mcheck = 1 if `i' != "Not applicable" & b1_4 == "No"
}
listtab $id_info `var_1' mcheck b1_4 if mcheck == 1, delimiter(",") appendto(`hfc_file') replace headlines(" ,Missing values in D2.4, on having regulated ODTIs") headchars(charname)
#delimit ;
local var_1 d2_4_a_2
d2_4_b_2
d2_4_c_2
d2_4_d_2
d2_4_e_2
d2_4_f_2
d2_4_g_2
d2_4_h_2
d2_4_i_2
d2_4_j_2
d2_4_k_2;
#delimit cr
#delimit ;
local var_2 d2_4_a_1
d2_4_b_1
d2_4_c_1
d2_4_d_1
d2_4_e_1
d2_4_f_1
d2_4_g_1
d2_4_h_1
d2_4_i_1
d2_4_j_1
d2_4_k_1;
#delimit cr
local n : word count `var_2'
//Skipping, If d2_4_a_1 != Yes but restricted, skip d2_4_a/k_2
capture drop skipcheck
gen skipcheck = 0
forvalues i = 1/`n' {
local a : word `i' of `var_1'
local b : word `i' of `var_2'
dis "`a'" "`b'"
replace skipcheck = 1 if (missing(`a') & `b' == "Yes but restricted")
}
br $id_info `var_1' skipcheck `var_2' if skipcheck == 1
listtab $id_info `var_1' skipcheck `var_2' if skipcheck == 1, delimiter(",") appendto(`hfc_file') replace headlines(" ,Skip values in D2.4 due to d2_4_a_1 != Yes but restricted, skip d2_4_a/k_2")headchars(charname)
///D2.5 Are “CCPs” permitted to carry out the following activities?
#delimit ;
local var_1 d2_5_a_1
d2_5_b_1
d2_5_c_1
d2_5_d_1
d2_5_e_1
d2_5_f_1
d2_5_g_1
d2_5_h_1
d2_5_i_1
d2_5_j_1;
#delimit cr
//Missing values, conditional on having regulated CCPs
capture drop mcheck
gen mcheck = 0
foreach i of local var_1 {
replace mcheck = 1 if `i' != "Not applicable" & b1_5 != "Yes"
}
br $id_info `var_1' mcheck b1_5 if mcheck == 1
listtab $id_info `var_1' mcheck b1_5 if mcheck == 1, delimiter(",") appendto(`hfc_file') replace headlines(" ,Missing values in D2.5, on having regulated CCPs") headchars(charname)
#delimit ;
local var_1 d2_5_a_2
d2_5_b_2
d2_5_c_2
d2_5_d_2
d2_5_e_2
d2_5_f_2
d2_5_g_2
d2_5_h_2
d2_5_i_2
d2_5_j_2;
#delimit cr
#delimit ;
local var_2 d2_5_a_1
d2_5_b_1
d2_5_c_1
d2_5_d_1
d2_5_e_1
d2_5_f_1
d2_5_g_1
d2_5_h_1
d2_5_i_1
d2_5_j_1;
#delimit cr
local n : word count `var_2'
//Skipping, If d2_5_a_1 != Yes but restricted, skip d2_5_a/k_2
capture drop skipcheck
gen skipcheck = 0
forvalues i = 1/`n' {
local a : word `i' of `var_1'
local b : word `i' of `var_2'
dis "`a'" "`b'"
replace skipcheck = 1 if (missing(`a') & `b' == "Yes but restricted")
}
br $id_info `var_1' skipcheck `var_2' if skipcheck == 1
listtab $id_info `var_1' skipcheck `var_2' if skipcheck == 1, delimiter(",") appendto(`hfc_file') replace headlines(" ,Skip values in D2.5 due to d2_5_a_1 != Yes but restricted, skip d2_5_a/k_2")headchars(charname)
///D2.6 Are “non-bank e-money issuers” permitted to carry out the following activities?
#delimit ;
local var_1 d2_6_a_1
d2_6_b_1
d2_6_c_1
d2_6_d_1
d2_6_e_1
d2_6_f_1
d2_6_g_1
d2_6_h_1
d2_6_i_1
d2_6_j_1
d2_6_k_1
d2_6_l_1;
#delimit cr
//Missing values, conditional on having regulated non-bank e-money issuers
capture drop mcheck
gen mcheck = 0
foreach i of local var_1 {
replace mcheck = 1 if `i' != "Not applicable" & b1_6 != "Yes"
}
br $id_info `var_1' mcheck b1_6 if mcheck == 1
listtab $id_info `var_1' mcheck b1_6 if mcheck == 1, delimiter(",") appendto(`hfc_file') replace headlines(" ,Missing values in D2.6, on having regulated non-bank e-money issuers") headchars(charname)
#delimit ;
local var_2 d2_6_a_2
d2_6_b_2
d2_6_c_2
d2_6_d_2
d2_6_e_2
d2_6_f_2
d2_6_g_2
d2_6_h_2
d2_6_i_2
d2_6_j_2
d2_6_k_2
d2_6_l_2;
#delimit cr
#delimit ;
local var_2 d2_6_a_1
d2_6_b_1
d2_6_c_1
d2_6_d_1
d2_6_e_1
d2_6_f_1
d2_6_g_1
d2_6_h_1
d2_6_i_1
d2_6_j_1
d2_6_k_1
d2_6_l_1;
#delimit cr
local n : word count `var_2'
//Skipping, If d2_6_a_1 != Yes but restricted, skip d2_6_a/l_2
capture drop skipcheck
gen skipcheck = 0
forvalues i = 1/`n' {
local a : word `i' of `var_1'
local b : word `i' of `var_2'
dis "`a'" "`b'"
replace skipcheck = 1 if (missing(`a') & `b' == "Yes but restricted")
}
br $id_info `var_1' skipcheck `var_2' if skipcheck == 1
listtab $id_info `var_1' skipcheck `var_2' if skipcheck == 1, delimiter(",") appendto(`hfc_file') replace headlines(" ,Skip values in D2.6 due to d2_6_a_1 != Yes but restricted, skip d2_6_a/l_2") headchars(charname)
///D3a. As part of rulemaking process, does your agency have a formal process to consult with the industry?
//Missing values, Need to have Yes/No/NA
capture drop mcheck
gen mcheck = 0
replace mcheck = 1 if missing(d3_a)
mdesc d3_a
listtab $id_info d3_a if mcheck == 1, delimiter(",") appendto(`hfc_file') replace headlines(" ,Missing values in D3a") headchars(charname)
///D3b. With what frequency do you consult with industry?
///D3c. Through what channel do you consult with industry? (Mark all that apply)
#delimit ;
local var_1 d3_b
d3_c_1_public_con
d3_c_2_engagement
d3_c_3_statutory_
d3_c_4_issuespec;
#delimit cr
//Missing values, conditional on having regulated non-bank e-money issuers
capture drop mcheck
gen mcheck = 0
foreach i of local var_1 {
replace mcheck = 1 if missing(`i') & d3_a != "Yes"
}
br $id_info `var_1' mcheck d3_a if mcheck == 1
//Cleaning
//Comment: Populates automatically No even if If d3_a = No|NA
foreach i of local var_1 {
replace `i' = "" if d3_a == "No"|d3_a == "NA"
}
br $id_info `var_1' mcheck d3_a if mcheck == 1
listtab $id_info `var_1' mcheck d3_a if mcheck == 1, delimiter(",") appendto(`hfc_file') replace headlines(" ,Missing values in D3b and D3c, on having a process to consult with the industry") headchars(charname)
///D4a. As part of rulemaking process, does your agency have a formal process to consult with the consumers?
//Missing values, Need to have Yes/No/NA
capture drop mcheck
gen mcheck = 0
replace mcheck = 1 if missing(d4_a)
mdesc d4_a
listtab $id_info d4_a if mcheck == 1, delimiter(",") appendto(`hfc_file') replace headlines(" ,Missing values in D4a") headchars(charname)
///D4b. With what frequency do you consult with consumers?
///D4c. Through what channel do you consult with consumers? (Mark all that apply)
#delimit ;
local var_1 d4_b
d4_c_1_public_con
d4_c_2_engagement
d4_c_3_statutory_
d4_c_4_issuespec;
#delimit cr
//Missing values, conditional on having regulated non-bank e-money issuers
capture drop mcheck
gen mcheck = 0
foreach i of local var_1 {
replace mcheck = 1 if missing(`i') & d4_a != "Yes"
}
br $id_info `var_1' mcheck d4_a if mcheck == 1
//Cleaning
//Comment: Populates automatically No even if If d4_a = No|NA
foreach i of local var_1 {
replace `i' = "" if d4_a == "No"|d4_a == "NA"
}
br $id_info `var_1' mcheck d4_a if mcheck == 1
listtab $id_info `var_1' mcheck d4_a if mcheck == 1, delimiter(",") appendto(`hfc_file') replace headlines(" ,Missing values in D4b and D4c, on having a process to consult with the industry") headchars(charname)