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

st: Re: decimal to binary conversion


From   Jeffrey Simons <[email protected]>
To   <[email protected]>
Subject   st: Re: decimal to binary conversion
Date   Wed, 10 Mar 2004 07:47:32 -0600

I want to take a variable that is in decimal format and convert it to a six
digit binary number. Then take that and form six new indicator variables.

For example,

. inbase 2 29
11101

Provides this. I would like to write a do file to loop through the values of
a variable and do this. Converting the answer to six new indicator
variables.

So if var1 took on values of 15, 29, 35, ...
I'd like to get

var1    v1a v1b v1c v1d v1e v1f
15      0   0   1   1   1   1
29      0   1   1   1   0   1
35      1   0   0   0   1   1
....

Any assistance would be most appreciated.

<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>
Jeffrey Simons, Ph.D.
Department of Psychology
The University of South Dakota
414 East Clark St.
Vermillion, SD 57069
Phone:      605-677-5353
Fax:        605-677-3195
<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>

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