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 at the end of May, and its replacement, statalist.org is already up and running.


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

Re: st: how do you drop repeated values in a variable to remain with only one?


From   Gwinyai Masukume <parturitions@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: how do you drop repeated values in a variable to remain with only one?
Date   Sun, 21 Apr 2013 12:18:57 +0200

Hi Modesto,
That works. Thanks.
Kind regards,
Gwinyai

On 4/21/13, Modesto Escobar <modesto@usal.es> wrote:
> Hi, Gwinyai:
> Being aware that data will be lost,  I think that you can solve your
> problem
> with this code:
> duplicates drop A, force
>
> I hope this works.
>
> Modesto Escobar
>
> -----Mensaje original-----
> De: owner-statalist@hsphsun2.harvard.edu
> [mailto:owner-statalist@hsphsun2.harvard.edu] En nombre de Gwinyai Masukume
> Enviado el: domingo, 21 de abril de 2013 11:18
> Para: statalist@hsphsun2.harvard.edu
> Asunto: Re: st: how do you drop repeated values in a variable to remain
> with
> only one?
>
> Dear Daniel and Nick,
>
> Thank you. Unfortunately, I could not reproduce the exact variable and
> values as patient information must be de-identified.
>
> Along with variable A, there is variable B, C, D, E, which can differ with
> the same value of A. I want to remain with a single value of A (I am aware
> data will be lost).
> I agree 'does not work' is not right. I am the one failing to figure out
> things. Please assist.
>
> Kind regards,
> Gwinyai
>
> On 4/21/13, Nick Cox <njcoxstata@gmail.com> wrote:
>> As the author of -duplicates-, I object strongly to the wording
>>
>> "does not work"
>>
>> here.
>>
>> 1. -duplicates- is designed to allow you to -drop- duplicates when
>> they merely repeat information, so it is entirely a feature that it
>> resists your use here.
>>
>> 2. The -force- option is nevertheless available to do what you want.
>> and is documented in the help.
>>
>> -force- specifies that observations duplicated with respect to a named
>> varlist be dropped.
>>         The -force- option is required when such a varlist is given as
>> a reminder that
>>         information may be lost by dropping observations, given that
>> those observations may
>>         differ on any variable not included in varlist.
>>
>> It is, however, a recipe for arbitarily discarding much of the
>> information in your data.
>>
>>
>> Nick
>>
>> Nick
>> njcoxstata@gmail.com
>>
>>
>> On 21 April 2013 07:51, Gwinyai Masukume <parturitions@gmail.com> wrote:
>>
>>> I have a dataset  with variable A, which has repeated  values:
>>>
>>> A
>>> 1
>>> 2
>>> 2
>>> 2
>>> 3
>>> 3
>>> 4
>>> 5
>>> 5
>>> 6
>>> 6
>>> 6
>>>
>>> Where the values are repeated e.g 2. I would like to drop the
>>> repeated values and remain with only a single 2.
>>> I have tried the duplicates drop command, but it does not work as the
>>> repeated values are not duplicates, but say different hospital visits
>>> by  the same individual.
>>> I would still like to drop repeated values of the variable A. How can
>>> I do this?
>>>
>> *
>> *   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/
>
*
*   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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index