Statalist


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

st: RE: easier way?


From   "Nick Cox" <n.j.cox@durham.ac.uk>
To   <statalist@hsphsun2.harvard.edu>
Subject   st: RE: easier way?
Date   Tue, 3 Jul 2007 21:16:41 +0100

What is "it" that you want to do? 

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

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. 

Your variable name structure makes looping a little difficult. 
Putting "indice" inside each variable name is awkward. 

Nick 
n.j.cox@durham.ac.uk 

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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index