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]

Re: st: drop duplicates iff


From   Joel Jönsson <[email protected]>
To   [email protected]
Subject   Re: st: drop duplicates iff
Date   Mon, 15 Apr 2013 10:27:07 +0200

Thanks for your quick response Nick. I have been looking at the documentation (help duplicates). 
My problem is to isolate the removal of duplicates to one Apartment-ID at the time. Which command [if] [in] [bysort] [group] do I use?

On Apr 15, 2013, at 1:48 AM, Nick Cox wrote:

> Did you try looking at the documentation? There is a -duplicates-
> command. Once you have used it to remove duplicates, the second
> question is
> 
> bysort Apartment_ID : replace Bidder_ID = _n
> 
> Nick
> [email protected]
> 
> 
> On 14 April 2013 23:19, Joel Jönsson <[email protected]> wrote:
>> 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/
> 
> *
> *   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/


*
*   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