Statalist


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: RE: st: panel data- assigning rank by country and year


From   "Nick Cox" <[email protected]>
To   <[email protected]>
Subject   RE: RE: st: panel data- assigning rank by country and year
Date   Thu, 15 Jan 2009 21:46:22 -0000

Your ranks will not exceed 1 if you have at most one observation for each combination of country and year, regardless of validity. 

I understood from your postings that you seek rankings within cross-combinations of country and year. That would be futile if your data are defined uniquely by country and year. 

You should show us a segment of your data if this is not clear. Do bear in mind that we rely entirely on what you say. 

Nick 
[email protected] 

[email protected]

Thanks Nick, this is now excluding the values less than 0. However, it appears to be assigning all the positive values as "1" as opposed to ranking them in order "1,2,3,4...." Am I doing something wrong?

----- Original Message -----
From: Nick Cox <[email protected]>
Date: Friday, January 16, 2009 6:31 am
Subject: RE: st: panel data- assigning rank by country and year
To: [email protected]

> I don't know what "does not seem to work" means in your case, 
> but one way forward is something like this. 
> 
> First, segregate observations that are good and bad for your 
> purpose. Let's say "good" observations are non-missing on these 
> variables and positive on -var-. 
> 
> gen byte good = !missing(year, Country, var) & (var > 0) 
> 
> Second, 
> 
> bysort good Country year : egen rank_var = rank(var) 
> 
> Third, use only 
> 
> ... if good 
> 
> Nick 
> [email protected] 
> 
> [email protected]
> 
> Further to my query below:
> I just found that I have a number of missing and negative 
> values. Is there anyway I can exclude these cases when I assign 
> the country ranks?
> 
> [email protected]
> 
> > I am trying to assign ranks to country observations within 
> > years. By this I mean that I want to assign a score for each 
> > observation (within a country) within that specific year. 
> > So far, I have calculated:
> > egen rank_var = rank(var) ---- this seems to provide ranks to 
> > countries, but does not take into account yearly changes.  
> > I tried: 
> > bysort year Count: egen rank_var= rank(var)--- but this does 
> not 
> > seem to work either. Is this something to do with 
> subscripting? 

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   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