From ddc0fed86637b76658b51b8f976ca8f569f06e9b Mon Sep 17 00:00:00 2001 From: David Date: Mon, 27 Jul 2020 13:44:30 -0400 Subject: [PATCH 1/6] Allows to change current server option: server0 --- pcn_compare.ado | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/pcn_compare.ado b/pcn_compare.ado index 33c1ab7..0032560 100644 --- a/pcn_compare.ado +++ b/pcn_compare.ado @@ -21,6 +21,7 @@ syntax [anything(name=subcmd id="subcommand")], /// IDvar(string) /// MAINv(string) /// server(string) /// +server0(string) /// DISvar(string) /// check(string) /// POVline(string) /// @@ -69,7 +70,9 @@ qui { if ("`disvar'" == "") loc disvar "main" else loc disvar = lower("`disvar'") - if ("`sdlevel'" == "") loc sdlevel = 2 + if ("`sdlevel'" == "") loc sdlevel = 2 + + if ("`server0'" != "") loc serverm = "server(`server0')" if !inlist("`check'","main","all") { noi di as err "Check varibables must be set to: main or all" @@ -120,7 +123,7 @@ qui { // Get current data povcalnet `wb', povline(`povline') /// country(`country') region(`region') /// - year(`year') `fillgaps' `aggregate' clear + year(`year') `serverm' `fillgaps' `aggregate' clear if ("`check'" == "main"){ keep `idvar' `mainv' From 5dff193129dc036d3b842e0c25198cb15bc6517e Mon Sep 17 00:00:00 2001 From: David Date: Mon, 27 Jul 2020 13:44:30 -0400 Subject: [PATCH 2/6] Allows to change current server option: server0 --- pcn_compare.ado | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/pcn_compare.ado b/pcn_compare.ado index 0bd7d41..4c8412f 100644 --- a/pcn_compare.ado +++ b/pcn_compare.ado @@ -21,6 +21,7 @@ syntax [anything(name=subcmd id="subcommand")], /// IDvar(string) /// MAINv(string) /// server(string) /// +server0(string) /// DISvar(string) /// check(string) /// POVline(string) /// @@ -69,7 +70,9 @@ qui { if ("`disvar'" == "") loc disvar "main" else loc disvar = lower("`disvar'") - if ("`sdlevel'" == "") loc sdlevel = 2 + if ("`sdlevel'" == "") loc sdlevel = 2 + + if ("`server0'" != "") loc serverm = "server(`server0')" if !inlist("`check'","main","all") { noi di as err "Check varibables must be set to: main or all" @@ -120,7 +123,7 @@ qui { // Get current data povcalnet `wb', povline(`povline') /// country(`country') region(`region') /// - year(`year') `fillgaps' `aggregate' clear + year(`year') `serverm' `fillgaps' `aggregate' clear if ("`check'" == "main"){ keep `idvar' `mainv' From 6b48b6d72f4f876e508394e475ad5bf7cf47371b Mon Sep 17 00:00:00 2001 From: David Date: Tue, 11 Aug 2020 19:17:31 -0400 Subject: [PATCH 3/6] Allows for povcalnet vintages pcn_production Incorporated --- pcn_compare.ado | 31 ++++++++++++++++++++++++------- 1 file changed, 24 insertions(+), 7 deletions(-) diff --git a/pcn_compare.ado b/pcn_compare.ado index 4c8412f..118f2b5 100644 --- a/pcn_compare.ado +++ b/pcn_compare.ado @@ -34,6 +34,8 @@ year(string) /// FILLgaps /// AGGregate /// wb /// +vintage(string) /// +vintage0(string) /// ] version 14 @@ -91,9 +93,16 @@ qui { ==================================================*/ // get testing data - povcalnet `wb', server(`server') povline(`povline') /// + if ("`vintage'" == ""){ + povcalnet `wb', server(`server') povline(`povline') /// country(`country') region(`region') /// year(`year') `fillgaps' `aggregate' clear + } + else{ + pcn_production load, server(`server') vintage(`vintage') clear + } + + replace povertyline=round(povertyline,.1) // some odd cases they do not quite match cap isid `idvar' if _rc { @@ -121,13 +130,21 @@ qui { save `serverd' // Get current data - povcalnet `wb', povline(`povline') /// - country(`country') region(`region') /// - year(`year') `serverm' `fillgaps' `aggregate' clear - - if ("`check'" == "main"){ - keep `idvar' `mainv' + if ("`vintage0'" == ""){ + povcalnet `wb', povline(`povline') /// + country(`country') region(`region') /// + year(`year') `serverm' `fillgaps' `aggregate' clear + + if ("`check'" == "main"){ + keep `idvar' `mainv' + } } + else{ + pcn_production load, `serverm' vintage(`vintage0') clear + } + + replace povertyline=round(povertyline,.1) + foreach mv of local mainv { replace `mv' = round(`mv', `tl') From be745277a31a1efa636173ca2547e80a9b9fc114 Mon Sep 17 00:00:00 2001 From: David Date: Tue, 11 Aug 2020 20:53:55 -0400 Subject: [PATCH 4/6] Small harmonisationfor old vinatges Tries to harmonise the old vintages with different structure to be able to compare. - No longer makes a distinction between national and national (aggregate) this helps make better matches --- pcn_compare.ado | 38 +++++++++++++++++++++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) diff --git a/pcn_compare.ado b/pcn_compare.ado index 118f2b5..5b233a3 100644 --- a/pcn_compare.ado +++ b/pcn_compare.ado @@ -57,7 +57,7 @@ qui { // relevant macros if ("`idvar'" == "" & "`aggregate'" != "") loc idvar "year povertyline " else if ("`idvar'" == "" & "`wb'" != "") loc idvar "regioncode year povertyline" - else if ("`idvar'" == "") loc idvar "regioncode countrycode year povertyline coveragetype datatype" + else if ("`idvar'" == "") loc idvar "countrycode year povertyline coveragetype datatype" else loc idvar = lower("`idvar'") if ("`mainv'" == "") loc mainv "headcount" @@ -100,6 +100,22 @@ qui { } else{ pcn_production load, server(`server') vintage(`vintage') clear + cap rename wbcode countrycode + if (!_rc){ + cap gen povertyline = 1.9 + cap replace surveyyear = round(surveyyear) + cap rename surveyyear + cap gen datatype = . + cap gen coveragetype = . + cap replace datatype = 1 if inlist(inc_con, "c", "C") + cap replace datatype = 2 if inlist(inc_con, "i", "I") + cap replace coveragetype = 2 if regexm(country, "(Urban)") & national == 0 + cap replace coveragetype = 1 if regexm(country, "(Rural)") & national == 0 + cap replace coveragetype = 3 if national == 1 + cap replace countrycode = substr(countrycode,1,3) + replace headcount = headcount/100 + replace gini = gini/100 + } } replace povertyline=round(povertyline,.1) // some odd cases they do not quite match @@ -126,6 +142,8 @@ qui { replace `mv' = round(`mv', `tl') } + replace coveragetype = 3 if coveragetype == 4 // One national + tempfile serverd save `serverd' @@ -141,6 +159,22 @@ qui { } else{ pcn_production load, `serverm' vintage(`vintage0') clear + cap rename wbcode countrycode + if (!_rc){ + cap gen povertyline = 1.9 + cap replace surveyyear = round(surveyyear) + cap rename surveyyear + cap gen datatype = . + cap gen coveragetype = . + cap replace datatype = 1 if inlist(inc_con, "c", "C") + cap replace datatype = 2 if inlist(inc_con, "i", "I") + cap replace coveragetype = 2 if regexm(country, "(Urban)") & national == 0 + cap replace coveragetype = 1 if regexm(country, "(Rural)") & national == 0 + cap replace coveragetype = 3 if national == 1 + cap replace countrycode = substr(countrycode,1,3) + replace headcount = headcount/100 + replace gini = gini/100 + } } replace povertyline=round(povertyline,.1) @@ -150,6 +184,8 @@ qui { replace `mv' = round(`mv', `tl') } + replace coveragetype = 3 if coveragetype == 4 // One national + tempfile PCN save `PCN' From 7086c5e6fe0665cd20ff760c02c4cec97655e84b Mon Sep 17 00:00:00 2001 From: David Date: Wed, 9 Sep 2020 16:51:14 -0400 Subject: [PATCH 5/6] adds urban in synths --- pcn_create.ado | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/pcn_create.ado b/pcn_create.ado index cf560e2..1eb5577 100644 --- a/pcn_create.ado +++ b/pcn_create.ado @@ -307,20 +307,19 @@ qui { cap isynth distribution, count(`country') year(`year') addvar(`addvar') server(AR) natppp /* */ `pause' `clear' `options' - - // condition for synth - replace welfare = welfare*(365/12) //to monthly - if ("`country'"== "CHN"){ - if ("`iscover'" == "R") keep if coverage == "Rural" - if ("`iscover'" == "U") keep if coverage == "Urban" - } - if (_rc) { local status "error. loading" local dlwnote "isynth distribution, count(`country') year(`year') addvar(`addvar') `pause' `clear' `options'" } else{ + // condition for synth + replace welfare = welfare*(365/12) //to monthly + if ("`country'"== "CHN"){ + if ("`iscover'" == "R") keep if coverage == "Rural" + if ("`iscover'" == "U") keep if coverage == "Urban" + } + gen urban = inlist(coveragetype, "urban", "Urban") } } @@ -460,8 +459,15 @@ qui { local cfiles "`rfile' `ufile' `wfile'" } // end of special cases else { - keep weight welfare - local urban "" + cap confirm variable urban + if (_rc){ + keep weight welfare + local urban "" + } + else{ + keep weight welfare urban + local urban "urban" + } tempfile wfile char _dta[cov] "" if ("`module'" == "isynth") char _dta[cov] "`iscover'" From a68a99471a9696da8d712b14b5bc88a83c936457 Mon Sep 17 00:00:00 2001 From: David Date: Wed, 9 Sep 2020 16:52:05 -0400 Subject: [PATCH 6/6] minor err handling --- pcn_compare.ado | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pcn_compare.ado b/pcn_compare.ado index 5b233a3..39a7e58 100644 --- a/pcn_compare.ado +++ b/pcn_compare.ado @@ -142,7 +142,7 @@ qui { replace `mv' = round(`mv', `tl') } - replace coveragetype = 3 if coveragetype == 4 // One national + cap replace coveragetype = 3 if coveragetype == 4 // One national tempfile serverd save `serverd' @@ -184,7 +184,7 @@ qui { replace `mv' = round(`mv', `tl') } - replace coveragetype = 3 if coveragetype == 4 // One national + cap replace coveragetype = 3 if coveragetype == 4 // One national tempfile PCN save `PCN'