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]

st: FW: Ranking a string variable


From   "Peci, Adriana (OAHPP)" <Adriana.Peci@oahpp.ca>
To   <statalist@hsphsun2.harvard.edu>
Subject   st: FW: Ranking a string variable
Date   Mon, 23 Jan 2012 13:11:46 -0500

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 when 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/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index