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 on April 23, and its replacement, statalist.org is already up and running.


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

st: RE: RE: detect unique values of onevariable into a new variable


From   Nick Cox <n.j.cox@durham.ac.uk>
To   "'statalist@hsphsun2.harvard.edu'" <statalist@hsphsun2.harvard.edu>
Subject   st: RE: RE: detect unique values of onevariable into a new variable
Date   Tue, 21 Dec 2010 13:08:58 +0000

Note in addition that this question was reviewed by Gary Longton and myself in 

SJ-8-4  dm0042  . . . . . . . . . . . .  Speaking Stata: Distinct observations
        (help distinct if installed)  . . . . . .  N. J. Cox and G. M. Longton
        Q4/08   SJ 8(4):557--568
        shows how to answer questions about distinct observations
        from first principles; provides a convenience command

Nick 
n.j.cox@durham.ac.uk 

Nick Cox

This question seems incomplete. 

When you say "unique" I guess you mean "distinct". In your example, only Germany is unique, i.e. occurs once only. 

Do you mean that you want to -drop- duplicates? That is the only way I can think of that answers your question as worded. If so, check out -duplicates-. 

I am assuming that by variable you mean variable in the Stata sense. If you mean something else -- say a macro -- check out -levelsof-. 

Robert Budras

I would like to know if and how I can detect unique values of one
variable and write them into a new variable.

For Example:

Country

Australia
Australia
Belgium
Belgium
Germany

I need a variable which is:
unique = "Australia" "Belgium" "Germany"

I don't need:
unique = "Australia" "Australia" "Belgium" "Belgium" "Germany"


*
*   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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index