Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down at the end of May, and its replacement, statalist.org is already up and running.


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

Re: st: RE: year-wise rank function for multi-level data


From   Apalak Khatua <apalakkhatua@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: RE: year-wise rank function for multi-level data
Date   Sat, 21 May 2011 14:39:18 +0530

Apologies for the delay in response. This is what I was looking for.
Thanks a lot!

Regards,
Apalak
IIM Calcutta - INDIA

On Wed, May 18, 2011 at 10:58 PM, Nick Cox <n.j.cox@durham.ac.uk> wrote:
> As I understand it you want something like this:
>
> egen tag = tag(bg_code time)
> egen rank = rank(bg_sales) if tag, by(time) field
> bysort bg_code time (rank) : replace rank = rank[1]
>
> Nick
> n.j.cox@durham.ac.uk
>
> Apalak Khatua
>
> I am using unbalanced panel data. There are multiple firms (firm_code)
> within a business group (bg_code). I am considering sales for each
> firm (i.e. firm_sales) as a proxy for firm size. So business group
> size/sales (bg_sales) would be the summation of all firm-level sales
> of that particular business group for that particular year (time).
> Which I am calculating by:
>
> egen bg_sales = total(firm_sales), by(bg_code time)
>
> Now I would like to get the year-wise rank variable of all business
> groups (bg_code) in terms of size (i.e. bg_sales) . Here the unique id
> can be defined by bg_code and year (not firm_code). The rank variable
> for the biggest business group (in terms of bg_sales or size of the
> business group) for that particular year should be 1 and so on. How to
> write the code to get this rank variable against each bg_code for each
> year?
>
>
> *
> *   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/
>

*
*   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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index