Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
From | Stuart Buck <stuartbuck@gmail.com> |
To | statalist@hsphsun2.harvard.edu |
Subject | st: Problem with gen command? |
Date | Wed, 7 Aug 2013 12:51:07 -0500 |
Just passing this along from a fellow researcher: Be careful with the stata gen command. I came across something concerning in stata which I wanted to share. I imported some NCES data which brought the ncesid in as a double numeric variable. I wanted to make a duplicate of the ncesid so I could do some manipulation without having to preserve/restore or reload the data. When I used: gen ncesid2=ncesid, the values created were a float numeric variable and were not equal to those in the ncesid variable. One of my coworkers and I figured out this was because the float type only used 4 bytes so it holds less information than the double type (8 bytes). Stata was changing the last few numbers in ncesid2 in order to make it fit in the 4 bytes allocated to a float. The big problem is that Stata does not give any notice when it does this. Further, if values are being shown in scientific notation, you may not be able to see the difference even if you put them side by side. -- Stuart Buck http://about.me/stuartbuck * * For searches and help try: * http://www.stata.com/help.cgi?search * http://www.stata.com/support/faqs/resources/statalist-faq/ * http://www.ats.ucla.edu/stat/stata/