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]

st: Generate variable seems to round numbers

From   Carter Rees <>
To   <>
Subject   st: Generate variable seems to round numbers
Date   Fri, 30 Dec 2011 13:17:01 -0700

Hi Statalist,

Working on a Mac Lion, Stata 12 MP4.

I am working with a data set that has variable ALT_AID stored as long
%10.0g. The variable is a unique identifier for a best friend the
respondent named on a survey. ALT_AID was originally stored as an 8
character string variable but I used -destring- to get it to its present
format (I didn't specify a format, I let it set to the -destring- default).

My issue is this: If I want to create a duplicate of ALT_AID variable is
use the command:


The first case listed in my data set says ALT_AID has a value of 95576948.
When I look at the variable ALT_AID_NEW in the editor I see it stored as
9.56e+07, clicking on the cell reveals a value of 95576944. If I use the
-tostring- command it returns an 8 character string variable with the same
value of 95576944. As you can see, my unique identifier is now off by 4
places in the new variable. This is happening in other cases as well with
numbers being off by 2 to 4 places.

I am wondering if this is supposed to be happening and I simply need to
pay closer attention to formatting decisions in the future. Or, is there
something amiss with how this being handled in Stata?

Thank you,


*   For searches and help try:

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