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: drop duplicates iff


From   Joel Jönsson <[email protected]>
To   [email protected]
Subject   st: drop duplicates iff
Date   Mon, 15 Apr 2013 00:19:48 +0200

Dear all Statalist users.

I'm quit new to Stata and I'm facing the following challenge. I wish to get rid of duplicates within a 
variable (Bidder-ID) for a specific observation number (Apartment-ID) only i.e. there are numerous 
of observations with the value 49, 50, 51 etc. within Bidder-ID which are allowed only once 
within the same Apartment-ID.  

_n 		Apartment-ID	Bidder-ID

1.		3345			49
2.		3345			49
3.		3345			50
4.		3345			51
5.		3345			50
6.		5780			49
7.		5780			50	
8. 		5780			49

I would like the result to look something like the following:

_n 		Apartment-ID	Bidder-ID
1.		3345			49
2.		3345			50
3.		3345			51
4.		5780			49
5.		5780			50	

Also, I wish to rename the observations in Bidder-ID (49,50,51) which could also take on numbers 
such as 2234, 2244, 2255 (they symbolize one unique bidder) to take on values equal to when they first 
appeared in Appartment-ID. So, if Bidder-ID 49, 50, 51, 2234, 2244, 2255 exist for the same 
Apartment-ID, then 49=1, 50=2, 51=3, 2234=4 etc., not necessarily in that order (2234=2, 51=1, 49=4 …).
 Thus, It would look something like this:

 _n 		Apartment-ID	Bidder-ID
1.		3345			1
2.		3345			2
3.		3345			3
4.		5780			1
5.		5780			2

Thank you for your time. 	
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/


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