Dear all,

I need to tabulate variable Y conditioned on different values another variable X can take. Currently, I am using the following code:
Code:
tabulate Y if X == 1
tabulate Y if X == 2
tabulate Y if X == 3
tabulate Y if X == 4
tabulate Y if X == 5
tabulate Y if X == 6
I am wondering if there is a more efficient code, perhaps using the foreach loop to do this. Many thanks in advance!