Statalist


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

Re: st: "cond" command


From   "Eva Poen" <[email protected]>
To   [email protected]
Subject   Re: st: "cond" command
Date   Thu, 11 Sep 2008 15:19:59 +0100

Leonor,

you told us what you did but not what you want to achieve. You
mentioned tabulation. What information do you want to display, and
how? There might be an easy way to do it, other than nested -cond()-
statements.

Speaking of which, you are lacking the b in -cond(x,a,b)- in your
outer -cond- statement. See -help cond-. Maybe

gen col = cond(pension == 1,cond(jub == 1, 1, 2),0)

is what you want? It will create a variable that is equal to 1 if
pension==1 and jub==1, equal to 2 if pension==1 and jub !=1, and zero
otherwiese. Note that the above does not account for missing values in
either pension or jub.

Hope this helps,
Eva


2008/9/11 Leonor Saravia <[email protected]>:
> 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/



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