Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


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

RE: st: FW: Ranking a string variable


From   "Peci, Adriana (OAHPP)" <[email protected]>
To   <[email protected]>
Subject   RE: st: FW: Ranking a string variable
Date   Mon, 23 Jan 2012 13:35:29 -0500

I tried but it ranked items by time rather than by department. 

Thanks,

Adriana 

-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Dimitriy V. Masterov
Sent: January 23, 2012 1:21 PM
To: [email protected]
Subject: Re: st: FW: Ranking a string variable

Does "bysort department time: gen rank=_n" do the trick?

DVM

On Mon, Jan 23, 2012 at 1:11 PM, Peci, Adriana (OAHPP)
<[email protected]> wrote:
>
> Hello stata listers,
>
> I need some help to rank a string variable by two other variables. My
> data are in a long form in which one observation is listed more than
> once.
> The variable of interest is Item purchased  which I would like to rank
> based on the Department that this item belongs to and
> The time whern this item was purchased.
> So if departments categories are A, B, C, D etc (string variable) which
> are listed more than once in the database and the items are unique
> values as  x, y, z,.(string variable) etc.
> I want to count items of each department by purchased time as 1, 2, 3,
> 4, 5. So in case of two items were purchased at the same time I want
> them to be randomly ranked as 1, 2 and not 1,1.
>
> I am trying to use the egen command:  bysort department time: egen rank
> =rank(item) but it doesn't work for a string variables.
>
> Can anyone help me with that ?
>
>
> Thank you so much,
>
>
> Adriana Peci
>
> *
> *   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/

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