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/