Hi

I have a dataset in which the unit of analysis is individual citizens. I then have a large number of variables showing whether a certain medicial document was fetched (1 equals fetched) in order to assess the citizens case. The relevant data for this questions looks like this:
citizen_id med1 med2 med3 med4 med5 med6
1 0 0 1 1 0 0
2 0 1 1 0 0 1
3 1 0 1 1 0 0
I need to know the most frequent combination of medicial documents fetched. In the example data above the answer would be med3 and med4, since both citizen 1 and 3 have both of these documents fetched.

I can think of one solution, which however would be very time consuming, which is to generate a variable showing the number of times two medicial documents are fetched together

Code:
gen medcomb = 0
replace medcomb = 1 if med1 ==1 & med2==1
replace medcomb = 2 if med1==1 & med3==1
replace medcomb = 3 if med1==1 & med4==1
...and so on. Having replaced medcomb with the 18 different values, the answer to my question could be given using
Code:
tab medcomb
. However, since the number of variables in my real data are much larger this solution would be too time consuming. So is there an easier solution? Perhaps using foreach?