Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: st: Generate variable seems to round numbers
From
Lars Folkestad <[email protected]>
To
"[email protected]" <[email protected]>
Subject
Re: st: Generate variable seems to round numbers
Date
Fri, 30 Dec 2011 21:37:29 +0100
Hi
Sorry for not giving you an aswere. This was discussed on this list a few days ago, but i cannot find the string on my phone. Its, as far as i remember, a presicions problem (se svend juuls book section 5.5 my copy is at my office) and something to do with how binary code is translated from and to string values.
Mvh
Lars Folkestad
Den 30/12/2011 kl. 21.21 skrev "Carter Rees" <[email protected]>:
> As a follow-up, the new variable ALT_AID_NEW has a format of float %9.0g
> before running the -tostring- command.
>
>
>
> 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:
>
> gen ALT_AID_NEW = ALT_AID
>
> 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,
>
> Carter
>
>
> *
> * For searches and help try:
> * http://www.stata.com/help.cgi?search
> * http://www.stata.com/support/statalist/faq
> * http://www.ats.ucla.edu/stat/stata/
>
>
> *
> * For searches and help try:
> * http://www.stata.com/help.cgi?search
> * http://www.stata.com/support/statalist/faq
> * http://www.ats.ucla.edu/stat/stata/
*
* For searches and help try:
* http://www.stata.com/help.cgi?search
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/