Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds popshare option #19

Merged
merged 19 commits into from
Jul 8, 2020
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 32 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 @@ -258,8 +259,26 @@ qui {
}
}

*---------- Poverty line
if ("`povline'" == "") local povline = 1.9
*---------- Poverty line/population share
if ("`popshare'" != ""){
if ("`povline'" != ""){
oi disp as err "povline and popshare cannot be used at the same time"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I Think this should be noi rather than oi

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awful typo, I'll fix it right away

error
}
else{
loc povline = ""
loc pcall = "popshare"
}
}
else if ("`povline'" == "") {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This condition is not mutually exclusive with the first condition and with the else statement. I think the problem is that these lines,

if ("`popshare'" != ""){
		if ("`povline'" != ""){

Should be just one line

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree, I'll adjust it

loc popshare = ""
loc povline = 1.9
loc pcall = "povline"
}
else{
loc popshare = ""
loc pcall = "povline"
}

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

local f = 0

foreach i_povline of local povline {
foreach i_povline of local `pcall' {
local ++f

/*==================================================
Expand All @@ -392,6 +411,7 @@ qui {
region("`region'") ///
year("`year'") ///
povline("`i_povline'") ///
popshare("`popshare'") ///
ppp("`i_ppp'") ///
coverage(`coverage') ///
server(`server') ///
Expand All @@ -410,16 +430,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 @@ -478,6 +505,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