Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down on April 23, and its replacement, statalist.org is already up and running.


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

st: generating variable from combination of three categorical variable


From   prakash singh <prakashbhu@gmail.com>
To   statalist <statalist@hsphsun2.harvard.edu>
Subject   st: generating variable from combination of three categorical variable
Date   Wed, 18 May 2011 05:10:56 -0700

Hello all

In my survey data, I have three categorical variable with 0, 1 and 2 as
three category.
Now I want to make a variable using combination of these three
variables.

The combination is such that generated variable var4 == 0 if
var1==0 & var2==0 & var3==0,
var4=1 if var1==1 & var2==1 & var3==1,
var4=2 if var1==2 & var2==2 & var3==2,
var4=1 if var1|var2|var3 is having 0 and 1 only
var4=2 if var1|var2|var3 is having 0 and 2 only
var4 is 3 if var1|var2|var3 is 0,1 and 2

for exmple (see below)

var1 var2 var3 var4
0     0     0      0
1    1     1       1
2    2      2      2
0    1     2       3
0    1      1      1
1    2      0      3

I am using stata10.



Regards
Prakash
*
*   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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index