Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: RE: translation between binary system and the decimal system.


From   "Nick Cox" <[email protected]>
To   <[email protected]>
Subject   st: RE: translation between binary system and the decimal system.
Date   Tue, 12 Oct 2004 15:43:47 +0100

See the -egen- function -base()- in the -egenmore- package 
from SSC, and the examples in the help to that package. 

Nick 
[email protected] 

Hans J. Baumgartner
 
> I’ve got data that is binary coded. That is, an observation 
> may belong 
> to category 1, 2, 3 , 4 or a combination amongst these categories. My 
> variable cat_id has the value of 1 1f it is in category 1; 2 
> if it is in 
> category 2; 4 if it is in category 3; and 8 if it is in 
> category 4. My 
> variable has the sum of these values, i.e. cat_id=9 means that my 
> observation is in category 1 and 4.
> 
> I would like to generate 4 dummies for a new category identification.
> 
> Cat_id       Cat4       Cat3         Cat2        Cat1
> 1            0           0           0            1
> 2            0           0           1            0
> 3            0           0           1            1
> 4            0           1           0            0          
> ...                                                           
> 10           1           0           1            0
> 11           0           0           1            1
> ...
> 
>   i.e. it is a simple translation between binary system and 
> the decimal system.
> Is there a command for this?

*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   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