Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: st: more than double precision (higher than 16 digit)

From   Nicola Man <>
To   "" <>
Subject   RE: st: more than double precision (higher than 16 digit)
Date   Mon, 29 Nov 2010 16:15:15 +1100

Dear Michael,

Thanks for the suggestion, but I really was interested in knowing if numbers can be stored with higher precision than double.

In case anyone is interested, it is a kind of social network data that identifies the person ("rdsc0") who recruited the current person through a unique identity variable (i.e. each digit in "rdsc0" identifies the next person up in the chain who recruited).  This means that the recruiter can be identified using this unique id (by scrapping off the last digit in "rdsc0").

As the identity variable ("rdsc0") is unique for each line of observation in my dataset, I had just serially numbered the observations using the following (though I think the egen group() method as you suggested would also work):

gen float Serial=_n

I need to identify variables (e.g. "parent" as the serial ID) for the person who recruited (identified in the variable "rdscer" in main_data.dta), so had done the following:

keep Serial rdsc0 wave_rdsc GendNew
rename rdsc0 rdscer
*Serial, GendNew and wave_rdsc are variables I want identified for the recruiter
rename Serial parent
rename GendNew rdscer_GN
rename wave_rdsc rdscer_wave

save "c:\Data\recruiter.dta", replace

use "C:\Data\main_data.dta", clear
*the using file recruiter.dta has to be sorted by rdscer: see help joinby for more info
joinby rdscer using "c:\Data\recruiter.dta" , unmatched(master) _merge(recruited) update replace

This works and perhaps a second question is how to write a simple ado program that does this so that the temporary file "c:\Data\recruiter.dta" does not need to be created (or whether there is a matching function that does this elegantly - a bit like the lookup function in Excel).  This question, however, sounds more like something for Tibit of the week.

Anyway, this detracts from my original question which was whether I can store this variable as a number.


Dear Nicola

  I wonder if you might make a new id variable based on the string variable like this...

sysuse auto
egen id = group(make)

Then you could use the new id variable for the program that requires the numeric id variable.

I hope that helps,

Michael N. Mitchell
Data Management Using Stata      -
A Visual Guide to Stata Graphics -
Stata tidbit of the week         -

-----Original Message-----
From: Nicola Man 
Sent: Monday, 29 November 2010 11:27 AM
Subject: more than double precision (higher than 16 digit)


I am having problems with precision for a numeric variable (it is an ID variable).  I have been keeping it as a string variable as there are more than 16 digits (the maximum number of exact digits stored in double precision, which problem I also encountered in other softwares like Excel and SPSS).

However, I now want to do some computation with a user-written program in STATA that needs it to be stored as a number.  Would be great if someone would help me with this.


*   For searches and help try:

© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index