Statalist


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: RE: RE: easier way?


From   "Sebastian Kruk" <[email protected]>
To   [email protected]
Subject   st: RE: RE: easier way?
Date   Wed, 4 Jul 2007 13:45:16 -0300

What is "it" that you want to do?
I have a household survey. I want to obtain data on the labour force
which is subcategorized by employed (when pobpcoac equals 2) and
unemployed (when pobpcoac equals 3 or 4 or 5), <14 years old (when
pobpcoac equals 1) and inactive population (when pobpcoac is between 6
and 11) by sex and chief or not of the house.

If you want just to get totals of variables, there is a command called -total-.
I want to get totals of variables under some restrictions.

Otherwise, there is little point in filling variables with constants,
unless you really >need those variables later.

If you really do, look at -foreach- as a way of looping over
variables. -search >foreach- will indicate sources of tutorials.

I'm just beginning to learn Stata.

Your variable name structure makes looping a little difficult.
I don't care about names, I just want to obtaing employed, unemployed,
and inactive population.

Putting "indice" inside each variable name is awkward.
Do you know spanish?

Nick
[email protected]
Sebastian Kruk

Are there a easier way of do it?

egen desocupados_indice  =  anycount (pobpcoac), values(3 4 5)

egen byte desocupados_indice_man = anycount(pobpcoac) if
e1==1, values(3 4 5)

egen byte desocupados_indice_man_jefe = anycount(pobpcoac) if e1==1 &
e3==1, values(3 4 5)

egen byte desocupados_indice_man_no_jefe = anycount(pobpcoac) if e1==1
& e3!=1, values(3 4 5)

egen byte desocupados_indice_woman = anycount(pobpcoac) if
e1==2, values(3 4 5)

egen byte desocupados_indice_woman_jefe = anycount(pobpcoac) if e1==2
& e3==1, values(3 4 5)

egen byte desocupados_indice_woman_no_jefe = anycount(pobpcoac) if
e1==2 & e3!=1, values(3 4 5)

egen desocupados = total(desocupados_indice)

egen desocupados_man = total(desocupados_indice_man)

egen desocupados_man_jefe = total(desocupados_indice_man_jefe)

egen desocupados_man_no_jefe = total(desocupados_indice_man_no_jefe)

egen desocupados_woman = total(desocupados_indice_woman)

egen desocupados_woman_jefe = total(desocupados_indice_woman_jefe)

egen desocupados_woman_no_jefe =
total(desocupados_indice_woman_no_jefe)

egen ocupados_indice  =  anycount (pobpcoac), values(2)

egen ocupados_indice_man = anycount(pobpcoac) if e1==1, values(2)

egen ocupados_indice_man_jefe = anycount(pobpcoac) if e1==1 & e3==1,
values(2)

egen ocupados_indice_man_no_jefe = anycount(pobpcoac) if e1==1 &
e3!=1, values(2)

egen ocupados_indice_woman = anycount(pobpcoac) if e1==2, values(2)

egen ocupados_indice_woman_jefe = anycount(pobpcoac) if e1==2
& e3==1, values(2)

egen ocupados_indice_woman_no_jefe = anycount(pobpcoac) if e1==2 &
e3!=1, values(2)

egen ocupados  =  total (ocupados_indice)

egen ocupados_man = total(ocupados_indice_man)

egen ocupados_man_jefe = total(ocupados_indice_man_jefe)

egen ocupados_man_no_jefe = total(ocupados_indice_man_no_jefe)

egen ocupados_woman = total(ocupados_indice_woman)

egen ocupados_woman_jefe = total(desocupados_indice_woman_jefe)

egen desocupados_woman_no_jefe =
total(desocupados_indice_woman_no_jefe)

generate pea=ocupados+desocupados

egen pei_indice  =  anycount (pobpcoac), values(6/11)

egen  pei =  total( pei_indice)

generate pet=pea+pei

egen pnet_indice  =  anycount (pobpcoac), values(1)

egen  pnet =  total( pnet_indice)

generate poblacion=pet+pnet

generate tasa_empleo=ocupados/pet

generate pet_ine=1620743

generate ocupados_expandidos=tasa_empleo*pet_ine
*
*   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