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]

st: number of distinct values for a variable in a group using -collapse-


From   Lloyd Dumont <[email protected]>
To   "[email protected]" <[email protected]>
Subject   st: number of distinct values for a variable in a group using -collapse-
Date   Fri, 24 Feb 2012 10:50:28 -0800 (PST)

Hello, everyone.
 
Here is a simple one.  I'll pose the question, and then I'll give an example, in case that helps.
 
Is there an extension to -collapse- that counts the number of distinct observations for a variable?
 
For example, say I have a dataset of individuals, each of whom is assigned to a group.  Each individual also has a job title, which is stored as a categorical.
 
So, let's say I wanted to -collapse- this dataset into a dataset of groups.  It would be easy to count the number of people in each group.  But, what if I also wanted to know the number of distinct job titles in each group?  For example, in some groups, all of the individuals would hold the same job title.  In other groups, each of the, say, 5 people in the group might have a different job title.
 
Thank you for your help!  Lloyd

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