Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: Trouble with confirm and looping.


From   [email protected]
To   <[email protected]>
Subject   st: Trouble with confirm and looping.
Date   Wed, 4 Aug 2004 12:58:15 -0400

Hi,

I have to produce a table which compares access to electricity by wealth groups
for a
number of african countries using DHS datas.

The wealth index variable is wlthind5, calculated using a factor analysis on a
set of
variables (radio, tv, elec, floor, wall, etc...).

wlthind5, as well as the variable used to construct it, are available for some
countries.
But in others, some of them contain missings or do not exist at all.

Therefore, I have to reconstruct the wealth index.

local countries "Niger Togo CIV Mali"
foreach i of local country {
cap confirm var wlthind5
if _rc==0 {
                 ta wlthind5, m
 }
else {                                              /*if  wlthind5 does not
exist */
           cap confirm var frige bike car radio tv elec floor wall rooms
/*check if these variables exist*/
           if _rc==0 {
                                factor frige bike car radio tv elec floor wall
rooms, pcf factors(5)
                               score wlthindf
                               kdensity wlthindf, normal
                               bys hhid: xtile wlthind5 [aw=hhweight], nq(5)
                               ta wlthind5, m
                            }
            }
}

But I just obtain nothing when I run the program (or sometimes, depending on the
country, frige -or another variable used in the factor- does not exists).

Any better idea on how to do it?

Thanks.

Amadou.

*
*   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/



© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index