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]

From |
Lloyd Dumont <lloyddumont@yahoo.com> |

To |
"statalist@hsphsun2.harvard.edu" <statalist@hsphsun2.harvard.edu> |

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/

**Follow-Ups**:**Re: st: number of distinct values for a variable in a group using -collapse-***From:*"Dimitriy V. Masterov" <dvmaster@gmail.com>

- Prev by Date:
**st: Problem while running a simple OLS regression** - Next by Date:
**st: Program to simulate AR(1) time series and return autocorrelations** - Previous by thread:
**st: Problem while running a simple OLS regression** - Next by thread:
**Re: st: number of distinct values for a variable in a group using -collapse-** - Index(es):