Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: st: Code to generate dummy variable from several categorical variables?


From   Nick Cox <[email protected]>
To   [email protected]
Subject   Re: st: Code to generate dummy variable from several categorical variables?
Date   Mon, 16 Jan 2012 00:55:31 +0000

The events

A==0
B==1
C==1

are as said not mutually exclusive. So, there seems no cause either
for surprise or for complaint. If you look at

egen group = group(A B C), label missing

all the distinct cross-combinations will be given distinct values.

. tab group

will then show your complete set-up.

If Stata is not doing what you want, you need to explain what you want
instead.

Nick

On Mon, Jan 16, 2012 at 12:41 AM, daniel klein
<[email protected]> wrote:

> I am not really getting what you are trying to do here (and whether it
> makes sense), since you are not giving any infromation on your
> variables, but would replacing the line
>
> replace abnlX=2 if C==1
>
> with
>
> replace abnlX=2 if C==1 & mi(abnlX)
>
> do what you want?
>
>
> As a side issue, note that this
>
> replace abnlX=2 if C==1 & (B==. | B==0 | B==1)
>
> can be written as
>
> replace abnlX=2 if C==1 & inlist(B, ., 0, 1)
>
> See -help inlist()- and -help functions-

Deborah L. Huang

> I'm looking for code to generate a dummy variable from values of
> several categorical variables which are not mutually exclusive. I've
> tried to do this using the generate and replace commands but Stata is
> changing the number of subjects in each dummy category as follows:
*
*   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–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index