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

Re: st: Generating a variable / Format problem?


From   Philip Ryan <[email protected]>
To   [email protected]
Subject   Re: st: Generating a variable / Format problem?
Date   Mon, 08 Aug 2005 15:15:50 +0930

Depending on your needs you could

(i) gen double temp = id

(ii) treat id as a string variable

You problem is most likely due to the limits of the computer in adequately representing the number of digits. Usually an id serves no analytical purpose and a string representation avoids these problems.

There are several FAQs on this topic available ( -findit precision-)

Phil



At 04:42 AM 8/08/2005 +0000, you wrote:

Dear Stata users,
I have a variable called id with 10 digits. I used "format id %15.0f" in order to be able to see all the digits in Stata.
My question is the following:
When I do:
"gen temp=id
format temp %15.0f"
for some weird reason, the new variable "temp" comes out with numbers different from the variable "id". But I want these two variables to be exactly the same!
Do you know why this is happening and what is the solution for this problem?
Thanks for your help,
MA_V

_________________________________________________________________
Don't just search. Find. Check out the new MSN Search! http://search.msn.click-url.com/go/onm00200636ave/direct/01/

*
* For searches and help try:
* http://www.stata.com/support/faqs/res/findit.html
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/
Philip Ryan
Associate Professor,
Department of Public Health
Associate Dean (Information Technology)
Faculty of Health Sciences
University of Adelaide 5005
South Australia
tel 61 8 8303 3570
fax 61 8 8223 4075
http://www.public-health.adelaide.edu.au/
CRICOS Provider Number 00123M
-----------------------------------------------------------
This email message is intended only for the addressee(s)
and contains information that may be confidential and/or
copyright. If you are not the intended recipient please
notify the sender by reply email and immediately delete
this email. Use, disclosure or reproduction of this email
by anyone other than the intended recipient(s) is strictly
prohibited. No representation is made that this email or
any attachments are free of viruses. Virus scanning is
recommended and is the responsibility of the recipient.

*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



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