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

st: RE: St: Dataset generation


From   "Nick Winter" <[email protected]>
To   <[email protected]>
Subject   st: RE: St: Dataset generation
Date   Fri, 14 Jun 2002 11:36:04 -0400

I think you want:

	. clear
	. set obs 81
	. range x -2 2
	. expand 81

The "imprecision" you are seeing is a side-effect of storing decimal
numbers in binary.  There is a FAQ somewhere on that.

--Nick W

-----------------------------------------------------------
 Nicholas Winter, Ph.D.                     P 202.939.5343
 Policy Studies Associates                  F 202.939.5732
 1718 Connecticut Avenue, NW     [email protected]
 Washington, DC 20009-1148           www.policystudies.com
----------------------------------------------------------- 

> -----Original Message-----
> From: [email protected] [mailto:[email protected]] 
> Sent: Friday, June 14, 2002 11:32 AM
> To: [email protected]
> Subject: st: St: Dataset generation
> 
> 
> Please could somebody explain to me how this could occur:
> 
> I want to generate a dataset with 6561 observations, with two 
> variables, let us say x and y, which take values between -2 and 2, 
> with step value 0.05. The aim of this is to test a function which I 
> have programmed which is causing some trouble. Therefore I need 81 
> occurences of x==-2, and 81 of x==-1.95 and so on for both x and y. 
> If I construct x as follows (crude so feel free to suggest 
> alternatives)
> 
> egen ind=fill (1 2)
> replace ind=ind-1
> gen x=int(ind/81)
> replace x=(x/20)-2
> 
> this should work, and does when the data is displayed to 2 decimal 
> places. However closer examination of the data with the data browser 
> shows some anomalies, where rather that x==-.95 it actually reads 
> x==.-9499999. This occurs for many values in between -1 and 1 and 
> attempts to rectify it using
> 
> gen x2=round(x,0.05)
> 
> have not bourne fruit. What am I missing?
> 
> Many thanks in advance,
> Julian
> ________________________________________________________________
> 
> DISCLAIMER:
> 
> This e-mail and any files transmitted with it are confidential
> and intended solely for the use of the individual or entity to
> whom it is addressed.  If you are not the intended recipient
> you are prohibited from using any of the information contained
> in this e-mail.  In such a case, please destroy all copies in
> your possession and notify the sender by reply e-mail.  Heriot
> Watt University does not accept liability or responsibility
> for changes made to this e-mail after it was sent, or for
> viruses transmitted through this e-mail.  Opinions, comments,
> conclusions and other information in this e-mail that do not
> relate to the official business of Heriot Watt University are
> not endorsed by it.
> ________________________________________________________________
> *
> *   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/
> 
*
*   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