help for deci version 2.0
get the newest version

Variable Base conversion

Description

deci provides a base conversion within various number system, for example, decimal, binary, hexadecimal, octal etc, which is based on the command
inbase and inten.

Note: varlist's missing values will be droped.

Syntax

deci
varlist
, from(numeric) to(numeric) [generate(string)]

* from(numeric) varlist number system, which must in range [2,62].

* to(numeric) the new number system, which must in range [2,62].

* generate(string) create a new variable. when left blank, varlist will be replaced.

Examples

. clear all

. set obs 1000

. gen x1=int(1000*runiform())

. gen str3 x2=string(x1)

. Convert variable 'x1' from decimal system to binary system and generate a new veriable 'x1_1':

. deci x1, f(10) t(2) gen(x1_1)

. Convert variable 'x2' from decimal system to octal system:

. deci x2, f(10) t(8)

. Convert variable 'x2' from octal system to binary system and generate a new veriable 'x2_1':

. deci x2, f(8) t(2) g(x2_1)

. Convert variable 'x2_1' from binary system to hexadecimal system:

. deci x2_1, f(2) t(16)

Bugs

deci does not verify that you do not use digits beyond the base.
For instance, you can type 'deci x, f(16) t(10)' while x[1]='1g'.

For problems and suggestions

Author: Liu wei, Yunnan University of Finance and Economics. Address: Longquan Road 237, Wuhua District, Kunming, Yunnan, P.R.China. ZIP Code: 650221.
E-mail: liuwei@ynufe.edu.cn

Also see

Other Commands I have written:

curvefit (if installed) ssc install curvefit (to install)

fdta (if installed) ssc install fdta (to install)

ftrans (if installed) ssc install ftrans (to install)

freplace (if installed) ssc install freplace (to install)

elife (if installed) ssc install elife (to install)

ftree (if installed) ssc install ftree (to install)

fren (if installed) ssc install fren (to install)

equation (if installed) ssc install equation (to install)