Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
From | Andreas Schmid <andreas.schmid@uni-bayreuth.de> |
To | statalist@hsphsun2.harvard.edu |
Subject | st: Programming: Ranking hospitals according to admissions in a dataset with patient level data |
Date | Mon, 19 Jul 2010 16:56:32 +0200 |
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/