Hello,
I'm annoyed by the following problem.
I issued the following commands.
----------
generate z_coef = .
replace z_coef = 5.10 if year == 1989
replace z_coef = 5.40 if year == 1990
replace z_coef = 5.55 if year == 1991 /*max*/
replace z_coef = 5.15 if year == 1992
replace z_coef = 4.00 if year == 1993
replace z_coef = 3.05 if year == 1994 /*min*/
replace z_coef = 3.78 if year == 1995
replace z_coef = 4.00 if year == 1996
replace z_coef = 3.50 if year == 1997
replace z_coef = 4.10 if year == 1998
replace z_coef = 4.10 if year == 1999
replace z_coef = 4.10 if year == 2000
replace z_coef = 4.10 if year == 2001
assert z_coef>=3.05 & z_coef<=5.55
----------
Then, Stata returned this error message:
7088 contradictions in 39384 observations
assertion is false
r(9);
Given the above simple commands, this message is
apparently hard to understand.
So, I checked the 'z_coef' variable in Stata editor.
Then, I found 5.55 actually stored as 5.5500002 and
so on (Of the above figures, 3.05,3.78 and 4.00 are
shown exactly as they are supposed to be)
According to '[U] 16.10 Precision and problems therein.',
this is because 'Stata stores numbers internally in
binary'.
I understand this logic, but this manner is sometimes
inconvenient, especially when one wants to perform
commands like -assertion-.
Though the manual recommends the use of float( ), like,
replace z_coef = float(5.55) if year == 1991
this mehod doesn't seem to deliver the goods; the
results are the same.
Though this phenomenon may not affect the data
analysis, it makes me somehow embarrassed, given the
above error message against -assertion-.
Is there any other way to deal with this problem?
Any suggestions welcome.
Thanks in advance.
K.I.
*
* 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/