Hello,
I have a dataset with 10 variables and 5 binary variables (A, B, C,D,E). I'm trying to get all possible combinations of 2,3, 4 and 5 of all but I'm not sure how to go about this using a loop/permin,combin in Stata. Moreover, I want Stata to count each combination iteration and tell me the sum of times each variable (intersection in combinations/permutations) is is 1.
The data is such that the number of A=1 (say 5) instances adds upto A=1 in all other iterations ( A=1 + B=1 +C=1 (2), A=1+C=1 (3). For example, I've been trying:
tab A if A !=0 & B !=0 & C !=0
I'm having difficulties getting the combinations with a loop (minimum code) and also tallying up all iterations to 5.
* Example generated by -dataex-. To install: ssc install dataex
clear
input byte(A B C D E)
1 0 0 0 1
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
1 0 0 0 1
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
1 0 0 0 1
1 0 0 0 0
0 0 0 0 0
1 0 0 0 0
1 0 0 0 0
1 0 0 0 0
1 0 0 0 0
0 0 0 0 0
1 0 0 0 0
1 0 0 0 0
1 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
1 0 0 0 0
1 0 0 0 1
1 0 0 0 1
0 0 0 0 0
1 0 0 0 0
0 0 0 0 0
1 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
1 0 0 0 0
0 0 0 0 0
1 0 0 0 0
1 0 0 0 0
1 0 0 0 0
0 0 0 0 0
1 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
1 0 0 0 1
1 0 0 0 1
1 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 1
0 0 0 0 0
0 0 0 0 0
1 0 0 0 0
0 0 0 0 0
1 0 0 0 0
0 0 0 0 0
0 0 0 0 0
1 0 0 0 0
1 0 0 0 0
1 0 0 0 0
1 0 0 0 0
Related Posts with Combinations of binary variables
Creating LoopHi I have codes for a few states - {3,4,5,6,1} and years -{ 2007,2008} and indexes- {3,5,2,4,5,2,4,…
eventstudy2 command: Estimation Window spans both before and after the event windowI am using the eventstudy2 command. In my research design, the estimation window spans before and af…
Questions on Stata command terminologyIf my indepvar is agegroup and have been categorized 31 to 40, 41 to 51 60 above 1. What is the su…
Why the ''observations" in the regressions are not integers?Dear friends, I have run some simple 2sls regressions. Some results show that the observations are n…
Esttab Indicate Option - Not Turning Off (Yes Instead of No)Hi all! I am using Stata 16. I am having an issue with esttab. I am running several regressions, an…
Subscribe to:
Post Comments (Atom)
0 Response to Combinations of binary variables
Post a Comment