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: strgroup


From   Nick Cox <njcoxstata@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: strgroup
Date   Tue, 22 Feb 2011 09:06:21 +0000

The problem was about editing strings, so comparing them with numeric
missing is illegal.

The essence of your code as copied here can be edited to

bysort s : keep if _n == 1

Renaming the variable or dropping other variables is naturally also possible.

My experience is that this kind of problem can be very messy, whatever
language you use. Much experience is condensed into

SJ-8-3  dm0039  . . .  Stata tip 64: Cleaning up user-entered string variables
        . . . . . . . . . . . . . . . . . . . . . . . .  J. Herrin and E. Poen
        Q3/08   SJ 8(3):444--445                                 (no commands)
        tip on how to clean up user-entered string variables

Nick

On Mon, Feb 21, 2011 at 9:59 PM, Liao, Junlin <junlin-liao@uiowa.edu> wrote:

> Here's my approach, suppose you have s variable holds string data of this fashion.
>
> by s, sort: gen s_unique=s if _n==1
> drop if s_unique==.
> keep s_unique
>
*
*   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/


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