Thanks, Nick. Your code with -egen- is simplier. However, you will get the
same problem. The values for "median" in Q1 are 1.4300001 and float()
doesn't recognize this value.
.list if median=float(1.43)
.(no observations)
Paul
-----Original Message-----
From: Nick Cox [mailto:[email protected]]
Sent: Wednesday, September 25, 2002 2:59 PM
To: [email protected]
Subject: st: RE: observation about float()
There will be more subtle advice, but my suggestion is that the
best way to solve this problem is to avoid it altogether.
In effect, you are overwriting a variable which would
be useful later.
Instead of
> xtile varx=var, nq(4)
> sort varx
> forvalues num=1/4 {
> sum var if varx==`num', de
> replace varx=r(p50) if varx==`num'
> }
go
xtile varx=var, nq(4)
generate median = .
forvalues num=1/4 {
sum var if varx==`num', de
replace median = r(p50) if varx==`num'
}
or
xtile varx = var, nq(4)
egen median = median(var), by(varx)
and then later
list if varx==1
and so on.
That way, you never need spend any time worrying
about how Stata is treating the binary-decimal
conversion.
Nick
[email protected]
*
* 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/