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

From |
"Eva Poen" <eva.poen@gmail.com> |

To |
statalist@hsphsun2.harvard.edu |

Subject |
Re: st: Re: "cond" command |

Date |
Thu, 11 Sep 2008 20:07:19 +0100 |

Leonor, that's clearer now. You could of course do -tabulate pension jub-, and the same for the other variables, but then it wouldn't be in one table. Will the number of ones and the total number of observations be enough? In this case, tabstat jub inv sob, by(pension) stats(sum count) will do. If you want the table as you drew it, here is one way to do this. ** generate some test data clear set obs 100 gen pension = mod(_n,3) gen jub = uniform()>0.4 gen inv = uniform()>0.5 gen sob = uniform()>0.6 preserve collapse jub inv sob (count) count=jub, by(pension) foreach x of varlist jub inv sob { gen `x'_1 = round(count*`x',1) gen `x'_0 = count -count*`x' } list pension jub_1 jub_0 inv_1 inv_0 sob_1 sob_0 count restore **** Here is another way, using the same test data: *** sort pension foreach x in jub inv sob { by pension: gen `x'_1 = sum(`x'==1) by pension: gen `x'_0 = sum(`x'==0) by pension: replace `x'_1 = `x'_1[_N] by pension: replace `x'_0 = `x'_0[_N] } tabstat jub_1 jub_0 inv_1 inv_0 sob_1 sob_0, by(pension) *** Hope this helps, Eva 2008/9/11 Leonor Saravia <lmisaravia@gmail.com>: > Eva and Nick, > > I really appreciate your help! > > What I need to do is this: > I have three variables: jub = (1, 0) ; inv = (1,0) ; sob = (1,0) > and I need to look the number of observations that satisfy each > condition, ei, I need to know how many persons "have" jub == 1 or jub > == 0; how many have inv == 1 or inv == 0 and how many hve sob == 1 or > sob == 0. > So, that´s why I thought that I could generate another variable > (pension = jub + inv + sob) which might be useful to order the > obervations. > The kind of table I´d like to construct is something like this (that´s > why I thought that using the 'cond' function was right): > > pension | jub | inv | > sob | > | if == 1 | if == 0| if == 1 | if == 0| if == 1 | > if == 0| > 1 | N 1 | N0 | n1 | n0 | x1 > | x0 | > 2 | N 1 | N0 | n1 | n0 | x1 > | x0 | > 3 | N 1 | N0 | n1 | n0 | x1 > | x0 | > 0 | N 1 | N0 | n1 | n0 | x1 > | x0 | > > > Thank you very much for your time and your help! :) > > Leonor > > > 2008/9/11, Leonor Saravia <lmisaravia@gmail.com>: >> Hello Statalisters, >> >> I'm trying to tabulate some information, but I´m having problems doing >> it, so I´d appreciate if you could see it and tell me what's what I´m >> doing wrong. >> >> What I did, was: >> >> gen col = cond(pension == 1, /// >> cond(jub == 1, 1, 2)) >> >> label define col 1 "pension, jub" /// >> 2 "pension, Sobrevivencia" /// >> >> label value col col >> >> Where the variables have this information: pension = (0,1, 2) >> jub = (0,1) >> >> >> Thank you very much!! >> >> Leonor >> * * For searches and help try: * http://www.stata.com/help.cgi?search * http://www.stata.com/support/statalist/faq * http://www.ats.ucla.edu/stat/stata/

**Follow-Ups**:**Re: st: Re: "cond" command***From:*"Eva Poen" <eva.poen@gmail.com>

**References**:**st: "cond" command***From:*"Leonor Saravia" <lmisaravia@gmail.com>

**st: Re: "cond" command***From:*"Leonor Saravia" <lmisaravia@gmail.com>

- Prev by Date:
**st: VWLS for Trend Analysis** - Next by Date:
**Re: st: Re: "cond" command** - Previous by thread:
**st: Re: "cond" command** - Next by thread:
**Re: st: Re: "cond" command** - Index(es):

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