Dear statalist members,

I have a sample of about 1 million people (id) with one or more records in one or more categories (cat), 15 categories in total. In summary:

id cat
id1 cat1
id2 cat1
id2 cat1
id3 cat1
id3 cat3
… …

I'm trying to find out how many people have at least one record in different categories and what are these categories. I am not interested in other people (people with just one record or several records in one category). In summary, I would like to have a result of the type:

At least one record in cat1 and cat2: 1000 people;
At least one record in cat1 and cat3: 500 people;
At least one record in cat1, cat2 and cat3: 200 people;
...

For now, I have only managed to count the number of people with one or more records in general:

bysort id:gen obs=_N
bysort id:gen obs2=_n
keep if obs2==1
tab obs

Could someone tell me how I could solve this problem?

Many thanks,

Maxime
(Stata 13.1)