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

st: St: Dataset generation


From   [email protected]
To   [email protected]
Subject   st: St: Dataset generation
Date   Fri, 14 Jun 2002 16:32:20 +0100 (BST)

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/



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