1
votes

I have a dataset with tree variables, three binary variables.

I wrote a proc tabulate

proc tabulate data=mydata;
class country var1 var2;
table Country, var1 var2;
run;

    Var1    Var2    
    0   1   0   1
USA 40  50  40  50
AUS 50  20  50  20
IRE 60  40  60  40
DUB 70  50  70  50

Here I get the table with the totals of both var 1 var 2 for 0s and 1s.

However I want only the totals of 1s in this cross table. How can I do that.

If I use a where caluse as below, it shows only 1ns both..

proc tabulate data=mydata;
class country var1 var2;
table Country, var1 var2;
where var1=1 and var2=2;
run;

When I use the above it brings out only the 1s present in both at the sametime. Which is not I am looking for. So the dataset I want is as below.

    Var1 Var2
    1   1
USA 50  50
AUS 20  20
IRE 40  40
DUB 50  50

Is there any other way of doing this?

2

2 Answers

1
votes

Change and to or.

   Truth table for
   Var1=1, Var2=1

             Include?
Var1 Var2  AND      OR
0    0      N       N
0    1      N       Y
1    0      N       Y
1    1      Y       Y
0
votes

Since your variables are coded 0,1 you can ask for the SUM statistic to get the "count" of the number of ones.

proc tabulate data=mydata;
   class country;
   var var1 var2;
   table Country, var1*sum var2*sum;
run;