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

st: Error in egen rank(), unique?

From   "Kaulisch, Marc" <>
To   <>
Subject   st: Error in egen rank(), unique?
Date   Tue, 3 Nov 2009 11:26:54 +0100

I have a problem with an egen rank(), unique command (Stata version 10.1). It looks like it does not produce the unique values as I like.
This is my start to rank episodes by their beginning (dbep). First I reshape the dataset into the long-format.
. reshape long dbep deep durep, i(id) j(episode)
. by id, sort: egen rank_dbep = rank(dbep), unique
. by id, sort: egen rank_deep = rank(deep), unique
. by id, sort: replace rank_dbep = _n if rank_dbep[_n] == .
. sort id rank_dbep
When I do want to transform this dataset back in the wide format:
. drop episode
. reshape wide dbep deep durep rank_deep , i(id) j(rank_dbep)
I receive the following error:
rank_dbep not unique within id;
there are multiple observations at the same rank_dbep within id.
Type "reshape error" for a listing of the problem observations.
reshape error gives out the number of 15 cases in which rank_dbep is not unique.
Strangely enough with a different dataset the same commands work just fine.
Any ideas?

Marc Kaulisch

Institut für Forschungsinformation und Qualitätssicherung
Godesberger Allee 90
53175 Bonn, Germany
Tel.: *49 - 228 - 9 72 73 - 25
Fax: *49 - 228 - 9 72 73 - 49

*   For searches and help try:

© Copyright 1996–2015 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index