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

Re: st: RE: rank error?


From   Jeph Herrin <[email protected]>
To   [email protected]
Subject   Re: st: RE: rank error?
Date   Wed, 28 May 2003 14:13:18 -0400

Nick Cox wrote:
Not clear to me that -group(X)- assigns values in
order of increasing  X (even if, as E Berkhout suggests
in a separate posting, I sort -sort X- first).


...

A look at the code for each shows that both produce sorted values and that's the intent in each case.
-levels- is not appropriate directly for problems in which categories are defined by numbers with fractional parts. Otherwise I can't comment further on what is not clear to you without knowing what your doubts are.
Well, when I look at the documentation for these two,
neither mentions anything about returning sorted values.
That raises some doubt. And when I look at the code for
-egen-'s -group- I see

		sort `touse' `varlist'
		quietly by `touse' `varlist': /*
			*/ gen `type' `g'=1 if _n==1 & `touse'
		replace `g'=sum(`g')

- it's not clear to me that I don't need the last line to have
one inserted before it
                sort `varlist'
		replace `g'=sum(`g')

to get the ordering (of -g- on `varlist') you say is clearly intended.
Is the preceeding -by : gen- guaranteed not to unsort the -sort-? Not
the sort of thing I usually count on. So there's another reason for doubt.

Sure, I could add the line and restore my confidence, but I
don't like fiddling with official Stata code. Or, I could test
out -egen-'s -group- to see if it has the behaviour I want, but
obviously it was much easier to code my own ranking.

Thanks again.

cheers,
Jeph



*
*   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