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 ?
<istmt>: 3499 control(), mata function, not found... an error occurred when simulate executed cfsimuI have written the following do file to conduct some Monte Carlo simulation. However, for some reaso…
How can I convert Variable names into the value of a new variable - in Stata?Dear All, I have a dataset that looks like this: year a b c ... 2000 value value value 20…
Suest after a list?Dear all I have a list of coefficient and standard error averages (following my previous post 15766…
I want to regress the cumulative returns for each month, using*the most recent available data for all other variables.This is what my data looks like for one particular stock with the id 10104 (id variable is PERMNO): …
Age calculated from months and yearsHi, I know that many questions have been posted about working with dates in Stata. I have not been …
Subscribe to:
Post Comments (Atom)
0 Response to IDs in different categories : how to count ?
Post a Comment