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)
Related Posts with IDs in different categories : how to count ?
invalid name error r(198);Good afternoon guys, I am very new at Stata and i was trying to learn a code below and it give me er…
option measure() not allowed r(198)Hi, I am a newbie to using Stata and Meta-analysis. When I entered "metabias logor selogor, begg" or…
invalid name J error r(198);Good afternoon guys, I am very new at Stata and i was trying to learn a code below and it give me er…
Box-Tidwell Test for Linearity of Logit Regression and RemediesDear all, I am using a Logit Regression to see if companies did recover to their pre-crisis ROA lev…
duration of employment spells by personal idHi! I would like to calculate duration of low wage employment (dummy 0/1) for each individual in my…
Subscribe to:
Post Comments (Atom)
0 Response to IDs in different categories : how to count ?
Post a Comment