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

Re: st: Benford's Law

From   "Svend Juul" <SJ@SOCI.AU.DK>
To   <>
Subject   Re: st: Benford's Law
Date   Wed, 30 Nov 2005 15:23:53 +0100

Michael wrote:
Does anyone have an easy way to identify the leading digit for each
entry in a diverse data set other than a series of inequality filters?

If you convert numbers to strings it is easy to identify the first
digit, as shown here:

set obs 100
gen x = int(1000*uniform())
gen str10 xstr = string(x , "%6.0f")
gen strx1 = substr(xstr,1,1)
destring strx1 , generate(x1)

Hope this helps

Svend Juul
Institut for Folkesundhed, Afdeling for Epidemiologi
(Institute of Public Health, Department of Epidemiology)
Vennelyst Boulevard 6
DK-8000  Aarhus C, Denmark
Phone: +45 8942 6090
Home:  +45 8693 7796

*   For searches and help try:

© Copyright 1996–2017 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index