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: Problem with gen command?
From
Richard Goldstein <[email protected]>
To
[email protected]
Subject
Re: st: Problem with gen command?
Date
Wed, 07 Aug 2013 13:55:08 -0400
if you want to make a copy of a variable, use the -clonevar- command
if you must use -gen-, then ensure you set the type to be exactly the
same as the variable you are "copying"
Rich
On 8/7/13 1:51 PM, Stuart Buck wrote:
> 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.
>
*
* 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/