Thanks Nick for this quick response.
I build on it to create a command.
My goals is to compute poverty rates and use
them later in other calculus (growth and sectoral
decompositions).
But I now encounter a problem with syntax command.
My do file is:
------------------------------------------------------------------------------------------------------------------
global po "[aw=hhweight]"
_pctile assetsp2002 $po if year == 02, nq(10) /*Asset index*/
global povline02 = r(r6)
cap prog drop difgt2
prog difgt2
set more 1
version 8.2
syntax varlist(min=1) [if] [in] [aweight fweight pweight iweight] [, ///
INCvar(string) YEARvar(string) YEARVal(integer) PL(numeric 0) ]
tokenize `varlist'
marksample touse
tempvar P0 P1 P2
while "`1'"~="" {
g `P0'=.
g `P1'=.
g `P2'=.
levels `1', local(R)
qui foreach r of local R {
povdeco `incvar' `weight' if `touse' &
`yearvar'==`yearval' & `1'==`r', pl(`pl')
replace P0 = $S_FGT0
replace P1 = $S_FGT1
replace P2 = $S_FGT2
global P0_`yearval'_`1'_`r' = $S_FGT0
global P1_`yearval'_`1'_`r' = $S_FGT1
global P2_`yearval'_`1'_`r' = $S_FGT2
di $P0_`yearval'_`1'_`r'
/*Since $S_FGT0 is common, save it in other macro*/
di $P1_`yearval'_`1'_`r'
di $P2_`yearval'_`1'_`r'
}
tabdisp `1' `weight', c(P0 P1 P2)
drop P0 P1 P2
mac shift
}
end
-------------------------------------------------------------------------------------------------------------------------------
When I launch, I get:
. difgt2 agegrp $po, inc(assetsp2002) year(year) yearv(02) pl($povline02)
----------------------------------------------------------------- begin difgt2
---
- set more 1
- version 8.2
- syntax varlist(min=1) [if] [in] [aweight fweight pweight iweight] [,
INCvar(stri
> ng) YEARvar(string) YEARVal(integer) PL(numeric 0) ]
invalid syntax
------------------------------------------------------------------- end difgt2
---
r(197);
When I try "args" instead of "syntax", it returns :
P0_02_agegrp _1 invalid name
Any help on this?
"Nick Cox"
<[email protected]> To: <[email protected]>
Sent by: cc:
owner-statalist@hsphsun2. Subject: st: RE: Problems to retrieve poverty lines
harvard.edu after povdeco (+ some questions). (Q1)
11/04/2004 10:48 AM
Please respond to
statalist
Use -foreach- with -levels-. More generally,
see
http://www.stata.com/support/faqs/data/foreach.html
gen P0 = .
gen P1 = .
gen P2 = .
levels region, local(R)
qui foreach r of local R {
povdeco pcexp [aw=wei] if region==`r', pl(20000)
replace P0 = $FGT0 if region == `r'
...
}
tabdisp region, c(P0 P1 P2)
Nick
[email protected]
[email protected]
> - I am using povdeco to compute poverty lines.
> I could retrieve the 3 poverty measures when I use povdeco
> without the by() option, through the macros $FGT0 $FGT1 $FGT2.
> But I have a problem retrieving these measures when I apply the by()
> option.
> The "ret li" returns only the total number of observations (r(N)).
> How to retrieve the poverty rates for each value (ie the X1,
> X2, ... X6 below)?
>
> povdeco pcexp [aw=wei], pl(20000)
> ret li
> local P0=$FGT0
> local P1=$FGT1
> local P2=$FGT2
>
> povdeco pcexp [aw=wei], pl(20000) by(urbrur)
>
> P0 P1
> P2
> -------------------------------------------------------------------
> Urban X1 X2 X3
> Rural X4 X5 X6
>
> ret li
> . r(N)=7890
>
> Actually, I am getting around by doing:
> povdeco pcexp [aw=wei], pl(20000) by(region)
> povdeco pcexp [aw=wei] if region==1, pl(20000)
> (save results in a macro)
> povdeco pcexp [aw=wei] if region==2, pl(20000)
> povdeco pcexp [aw=wei] if region==3, pl(20000)
>
> etc.,
> but this could be painful if we have many regions.
>
*
* For searches and help try:
* http://www.stata.com/support/faqs/res/findit.html
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/
*
* For searches and help try:
* http://www.stata.com/support/faqs/res/findit.html
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/