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 ?
Calculating time between specific events in panel dataHello, I have panel data with 1 to 10 events per patid. The eventdate is the date of the stroke and…
extracting several string values from several different variablesHello, i am working with treatment data i have treatment1 treatment2 treatment3 treatmentn variables…
How to interpret predicted probabilities with continious variables in logistic regression?Hello everyone, I've got a question regarding how to interpret continious variables in logistic reg…
Can I match on a baseline dataset from 2018 (treatment) and 2020 (control)?Dear Statalisters, I am currently writing my thesis on the topic of Multidimensional Empowerment. F…
How to identify all cases with missing observationDear All How can I identify and list all cases with missing observation(denoted by .a) from a data …
Subscribe to:
Post Comments (Atom)
0 Response to IDs in different categories : how to count ?
Post a Comment