Anthony Martin
Anthony Martin

Reputation: 787

SAS : proc freq on 3 categorical variables

I have data with

I would like to have the poverty rate of each of my var1 * var2 possible value, that would look like that :

enter image description here

But with three variables in a proc freq, I get multiple outputs, one for each value of the first variable I put on my product

proc freq data=test;
table var1*var2*poor;
run;

How can I get something close to what I would like ?

Upvotes: 1

Views: 2642

Answers (1)

Majdi
Majdi

Reputation: 133

Try this

    data test;
    input var1 var2 poor;
    cards;

    1 1 1
    2 3 0
    3 2 1
    4 1 1
    1 2 1
    2 3 0
    4 1 0
    4 2 0
    3 1 1
    1 2 0
    3 2 0
    1 3 1
    3 3 0
    3 3 0
    3 3 1
    1 1 0
    2 2 0
    2 2 1
    2 2 1
    2 1 1
    2 1 1
    2 1 1

    ;
run;


proc tabulate data=test;
class var1 var2 poor;
tables var1,
       var2*poor*pctn<poor>={label="%"};
run;

Upvotes: 1

Related Questions