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 ?
Truncate Y-axis with twoway function graphHi, folks. I've been using Stata for data management and analysis for quite a few years, but I've re…
VARNAME dialog elementDear All, While programming a dialog one can use an option numeric for the VARNAME dialog elements,…
replacing data of two row in only one row.i have data like below Code: * Example generated by -dataex-. To install: ssc install dataex clear …
Pooled-Cross Sectional Data - nhis_alcohol.dtaHello, I am writing an Empirical Paper on the effect of alcohol on labor market outcomes. The data i…
Generating dummy based on company classificationHi everyone, I am looking to create a dummy variable based on another dummy variable for an identif…
Subscribe to:
Post Comments (Atom)
0 Response to IDs in different categories : how to count ?
Post a Comment