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

st: translation between binary system and the decimal system.


From   "Hans J. Baumgartner" <[email protected]>
To   [email protected]
Subject   st: translation between binary system and the decimal system.
Date   Tue, 12 Oct 2004 16:11:51 +0200

Dear statalist,

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?

Thanks

Hans

--
Hans J. Baumgartner DIW Berlin
German Institute for Economic Research
Dept. Public Economics
Königin-Luise-Str. 5; 14195 Berlin; Germany Tel.: +49/30/89789-307 Fax.: +49/30/89789-114
http://www.diw.de
http://www.hansbaumgartner.de


*
* 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