Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: RE: number of unique values within an observation

From   "Nick Cox" <>
To   <>
Subject   st: RE: number of unique values within an observation
Date   Sat, 1 Oct 2005 17:56:05 +0100

In addition to other answers, please note an FAQ on 
the question: 

How do I compute the number of distinct observations?

Terminology is troubled here: as a small child
I was told that unique meant something that 
occurred once only. But no matter:

. search unique

would have pointed you to the FAQ mentioned
above, which discusses general principles and a 
clutch of user-written programs. 


Scott Imberman
> I was wondering if there is s a simple way to count the number of
> unique values in a variable list for each observation.  For example, i
> am looking at the id numbers for colleges that a set of 
> student attends.
>  A student may list having attended a college in multiple years like
> this:
> year     id
> 1995     3
> 1996     2
> 1997     3
> 1998     3
> I want to know how many unique schools the student attended (in this
> example the answer is 2).  Thanks for your help.

*   For searches and help try:

© Copyright 1996–2017 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index