Skip to content

Commit

Permalink
Merge pull request #19 from worldbank/quantile_qp
Browse files Browse the repository at this point in the history
Adds popshare option
  • Loading branch information
randrescastaneda authored Jul 8, 2020
2 parents c4296ae + 75d3682 commit e526444
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 7 deletions.
42 changes: 38 additions & 4 deletions povcalnet.ado
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ COUNtry(string) ///
REGion(string) ///
YEAR(string) ///
POVline(numlist) ///
POPShare(numlist) ///
PPP(numlist) ///
AGGregate ///
CLEAR ///
Expand Down Expand Up @@ -281,8 +282,29 @@ qui {
}
}

*---------- Poverty line
if ("`povline'" == "") local povline = 1.9
*---------- Poverty line/population share

// Blank popshare and blank povline = default povline 1.9
if ("`popshare'" == "" & "`povline'" == "") {
local povline = 1.9
local pcall = "povline"
}

// defined popshare and defined povline = error
else if ("`popshare'" != "" & "`povline'" != "") {
noi disp as err "povline and popshare cannot be used at the same time"
error
}

// blank popshare and defined povline
else if ("`popshare'" == "" & "`povline'" != "") {
local pcall = "povline"
}

// defined popshare and blank povline
else {
local pcall = "popshare"
}

*---------- Info
if regexm("`subcommand'", "^info") {
Expand Down Expand Up @@ -405,7 +427,10 @@ qui {

local f = 0

foreach i_povline of local povline {
if ("`pcall'" == "povline") loc i_call "i_povline"
else loc i_call "i_popshare"

foreach `i_call' of local `pcall' {
local ++f

/*==================================================
Expand All @@ -415,6 +440,7 @@ qui {
region("`region'") ///
year("`year'") ///
povline("`i_povline'") ///
popshare("`i_popshare'") ///
ppp("`i_ppp'") ///
coverage(`coverage') ///
server(`server') ///
Expand All @@ -433,16 +459,23 @@ qui {
local query_pl = "`r(query_pl)'"
local query_ds = "`r(query_ds)'"
local query_pp = "`r(query_pp)'"
local query_ps = "`r(query_ps)'"

return local query_ys_`f' = "`query_ys'"
return local query_ct_`f' = "`query_ct'"
return local query_pl_`f' = "`query_pl'"
return local query_ds_`f' = "`query_ds'"
return local query_pp_`f' = "`query_pp'"
return local query_ps_`f' = "`query_ps'"
return local base = "`base'"

*---------- Query
local query = "`query_ys'&`query_ct'&`query_pl'`query_pp'`query_ds'&format=csv"
if ("`popshare'" == ""){
local query = "`query_ys'&`query_ct'&`query_pl'`query_pp'`query_ds'&format=csv"
}
else{
local query = "`query_ys'&`query_ct'&`query_ps'`query_pp'`query_ds'&format=csv"
}
return local query_`f' "`query'"
global pcn_query = "`query'"

Expand Down Expand Up @@ -501,6 +534,7 @@ qui {
if ("`query_ys'" != "") noi di as res "Year:" as txt "{p 4 6 2} `query_ys' {p_end}"
if ("`query_ct'" != "") noi di as res "Country:" as txt "{p 4 6 2} `query_ct' {p_end}"
if ("`query_pl'" != "") noi di as res "Poverty line:" as txt "{p 4 6 2} `query_pl' {p_end}"
if ("`query_ps'" != "") noi di as res "Population share:" as txt "{p 4 6 2} `query_ps' {p_end}"
if ("`query_ds'" != "") noi di as res "Aggregation:" as txt "{p 4 6 2} `query_ds' {p_end}"
if ("`query_pp'" != "") noi di as res "PPP:" as txt "{p 4 6 2} `query_pp' {p_end}"
noi di as res _dup(20) "-"
Expand Down
9 changes: 9 additions & 0 deletions povcalnet.sthlp
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ Cannot be used with option {it:country()}{p_end}
{synopt :{opt year:}(numlist|string)}list of years (accepts up to 10), or {it:all}, or {it:last}. Default "all".{p_end}
{synopt :{opt pov:line:}(#)}list of poverty lines (in 2011 PPP-adjusted USD) to calculate
poverty measures (accepts up to 5). Default is 1.9.{p_end}
{synopt :{opt pops:hare:}(#)}list of headcounts to calculate poverty lines (in 2011 PPP-adjusted USD) and poverty measures. No default. Do not combine with {opt pov:line:}{p_end}


{synoptset 27 tabbed}{...}
{synopthdr:Options}
Expand Down Expand Up @@ -202,6 +204,13 @@ When selecting multiple poverty lines, use less than 4 decimals and separate
each value with spaces. If left empty, the default poverty line of $1.9 is used.
Poverty lines are expressed in 2011 PPP-adjusted USD per capita per day.

{phang}
{opt povline(#)} The desired population share (headcount) for which the poverty lines as poverty measures will be calculated.
This has not default, and should not be combined with {opt povline}.
The resultng poverty lines are expressed in 2011 PPP-adjusted USD per capita per day.



{marker options}{...}
{p 40 20 2}(Go up to {it:{help povcalnet##sections:Sections Menu}}){p_end}
{title:Options description}
Expand Down
15 changes: 12 additions & 3 deletions povcalnet_query.ado
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ version 11.0
COUntry(string) ///
REGion(string) ///
POVLine(string) ///
POPShare(string) ///
PPP(string) ///
NOSUMmary ///
ISO ///
Expand Down Expand Up @@ -179,9 +180,17 @@ quietly {
}
return local query_ct = "`country_q'"

*---------- Poverty lines query
local povline_q = "PovertyLine=`povline'"
return local query_pl = "`povline_q'"
if ("`popshare'" != ""){
*----------Poppulation share query
local popshare_q = "QP=`popshare'"
return local query_ps = "`popshare_q'"
}
else {
*---------- Poverty lines query
local povline_q = "PovertyLine=`povline'"
return local query_pl = "`povline_q'"

}


} // end of qui
Expand Down

0 comments on commit e526444

Please sign in to comment.