Dear Statalist,
I am trying to use the tab command that accounts for the different participant IDs. However, tab sums across all participants.
Please see below for the dataex example:
Now, when I tab I get
while I intend to obtain a table that acknowledges that participants should only be counted once.
For example, it's true that action 0 occurred 10 times, but only by 3 different participants (2,7,8). Likewise, action 1 occurred 6 times, but only with participants 6 and 9. Lastly, action 3 happened 12 times but only with participants 1,3,4,5, and 10.
I would like a table that reflects this accordingly:
I have tried:
tab action, by ID (which led to the error: option by not allowed)
tab action if ID == ID (led to the same first outcome) (I tried to state that ID has to be the same)
distinct action (which showed the 3 distinct values of action)
distinct action ID (which showed the distinct values of action and ID)
bysort ID: tab action (which led to a list of all IDs) (not in the right format and not the goal since I have more than 10 distinct IDs)
Unfortunately, I have run out of options for what else to try.
I would be most grateful for any input, help, or comments.
Thank you very much!
I am trying to use the tab command that accounts for the different participant IDs. However, tab sums across all participants.
Please see below for the dataex example:
Code:
* Example generated by -dataex-. For more info, type help dataex clear input int ID float action 1 2 1 2 1 2 1 2 2 0 2 0 2 0 2 0 3 2 3 2 4 2 4 2 5 2 5 2 6 1 6 1 7 0 7 0 7 0 7 0 8 0 8 0 9 1 9 1 9 1 9 1 10 2 10 2 end
Code:
tab action
Code:
action | Freq. Percent Cum. ------------+----------------------------------- 0 | 10 35.71 35.71 1 | 6 21.43 57.14 2 | 12 42.86 100.00 ------------+----------------------------------- Total | 28 100.00
For example, it's true that action 0 occurred 10 times, but only by 3 different participants (2,7,8). Likewise, action 1 occurred 6 times, but only with participants 6 and 9. Lastly, action 3 happened 12 times but only with participants 1,3,4,5, and 10.
I would like a table that reflects this accordingly:
action | Frequency | Percent |
0 | 3 | 30% |
1 | 2 | 20% |
2 | 5 | 50% |
Total | 10 | 100% |
I have tried:
tab action, by ID (which led to the error: option by not allowed)
tab action if ID == ID (led to the same first outcome) (I tried to state that ID has to be the same)
distinct action (which showed the 3 distinct values of action)
distinct action ID (which showed the distinct values of action and ID)
bysort ID: tab action (which led to a list of all IDs) (not in the right format and not the goal since I have more than 10 distinct IDs)
Unfortunately, I have run out of options for what else to try.
I would be most grateful for any input, help, or comments.
Thank you very much!
Comment