Dear Statalist,
I have 2 variables, Y & X, where X is a categorical variable. I want the following value:
average_y if x==1 minus average_y if x==0.
I'd appreciate any insights. Thanks,
ps: I can do this manually by doing the following code:
sum y if x==0
sum y if x==1
then get their mean value and subtract by a calculator.
But since I have many variables and subgroups that I want to get the differences, I would want to get the differences more efficiently.
I have 2 variables, Y & X, where X is a categorical variable. I want the following value:
average_y if x==1 minus average_y if x==0.
I'd appreciate any insights. Thanks,
ps: I can do this manually by doing the following code:
sum y if x==0
sum y if x==1
then get their mean value and subtract by a calculator.
But since I have many variables and subgroups that I want to get the differences, I would want to get the differences more efficiently.
Comment