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

Re: st: RE: counting subgroups in a large group

From   "Jesper B. Sorensen" <>
Subject   Re: st: RE: counting subgroups in a large group
Date   Fri, 06 Jun 2003 15:27:05 -0400

bysort course section: gen flag=_n==1
by course: egen nsections=sum(flag)
drop flag

At 03:42 PM 6/6/2003 -0400, you wrote:
I need to find the number of groups in a larger group: the number of *sections
in a *course. Of course, I can do this:

sort course
by course: tabulate sections

One would then count the sections by eyeballing them in the tabulation, but
in my data, a course can have many many sections.

The conceptual idea would be analgous to this fantasy coding:

by course: codebook section

* For searches and help try:
Jesper B. Sørensen
Richard S. Leghorn (1939) Associate Professor of Strategic Management
Sloan School of Management
Massachusetts Institute of Technology
Cambridge, MA 02142
(617) 253 7945  -- voice
(617) 253 2660  -- fax

*   For searches and help try:

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