# st: RE: RE: easier way?

 From "Sebastian Kruk" To statalist@hsphsun2.harvard.edu 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
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 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 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 pet_ine=1620743

```*