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 on April 23, and its replacement, statalist.org is already up and running.


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

st: R: Programming: Ranking hospitals according to admissions in a dataset with patient level data


From   "Carlo Lazzaro" <carlo.lazzaro@tiscalinet.it>
To   <statalist@hsphsun2.harvard.edu>
Subject   st: R: Programming: Ranking hospitals according to admissions in a dataset with patient level data
Date   Mon, 19 Jul 2010 17:21:45 +0200

Andreas wrote:

"Is there any way to generate a variable ranking that gives in each 
observation the same rank for one particular hospital?"

Perhaps what follows can do the trick:
-------------code begins----------------------
set obs 10
g Patients = _n
g Hospital ="Alfa" in 1/3
replace Hospital="Beta" in 4/9
replace Hospital="Gamma" in 10
tab  Hospital, sort
g rank = 1 if Hospital =="Beta"
replace rank = 2 if Hospital =="Alfa"
replace rank = 3 if Hospital =="Gamma"
-------------code ends----------------------

HTH and Kind Regards,
Carlo

-----Messaggio originale-----
Da: owner-statalist@hsphsun2.harvard.edu
[mailto:owner-statalist@hsphsun2.harvard.edu] Per conto di Andreas Schmid
Inviato: lunedì 19 luglio 2010 16.57
A: statalist@hsphsun2.harvard.edu
Oggetto: st: Programming: Ranking hospitals according to admissions in a
dataset with patient level data

Dear Statalist users,

I am working with a patient dataset which contains information on each 
admitted patient as well as on the according hospitals. For further 
steps I need a rank number for each hospital according to admissions per 
year. The variable "admissions" already exists. As for each hospital 
there are a couple of thousand observations (i.e. patients), I can not 
just use egen ranking = rank(admissions), as this would try to rank each 
individual observation.

Is there any way to generate a variable ranking that gives in each 
observation the same rank for one particular hospital?

Example:
Hospital A has got 5000 admissions per year and is thus the second 
largest hospital according to admissions. Thus, for any patient admitted 
to hospital a the variable ranking shows "2".

Structure:
Hospital-ID Admissions Sex Age | RANKING
A 5000 male 15 | 2
A 5000 female 56 | 2
B 3000 male 60 | 6
A 5000 male 70 | 2
B 3000 male 71 | 6
...
...
...

Thanks a lot for your help!

Andreas

--
Andreas Schmid
University of Bayreuth
Germany
*
*   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