CarLaTeX
CarLaTeX

Reputation: 305

How to get a frequency table with 2 variable in rows and 1 in column?

With SAS I'd like to get a frequency table like this:

varA  varB       varC
             varC1  varC2
varA1 varB1     n1     n2
varA1 varB2     n3     n4    
varA2 varB1     n5     n6    
varA2 varB2     n7     n8

where varA/B/C are my variables, varA1, varA2, varB2, etc. are the values of my variables, and n1, n2, n3, etc are the frequency.

With

Proc freq data=myfile ORDER=DATA;
tables varA * varB * varC / norow nocol NOPERCENT NOCUM missing;
run;

I get separate tables for any value of varA.

Upvotes: 1

Views: 313

Answers (1)

PeterClemmensen
PeterClemmensen

Reputation: 4937

Here is how I would do it in PROC TABULATE

data have;
input a b c;
datalines;
1 2 2
2 3 1
3 1 2
2 2 1
3 1 2
;

proc tabulate data =  have;
   class a b c;
   table a*b, c*n='';
run;

Upvotes: 1

Related Questions