Wednesday, March 30, 2011

proc freq 和 proc tabulate 对变量的分析

Underneath is the data:

data table;
      input degree religion $ count @@;
      cards;
      1 fund 178  1 mod 138  1 lib 108
      2 fund 570  2 mod 648  2 lib 442
      3 fund 138  3 mod 252  3 lib 252
      ;
run;

We want to show in the table the count for the combination of each degree and religion.

If we want to do it in proc freq, we need to add weight for count as below:

proc freq data=table ;
      weight count;
      tables degree*religion / nopercent norow nocol;
run;

With proc tabulate and the default is sum, the code is:

proc tabulate data=table;
      var count;
      class degree religion;
      table degree*count, religion;
run;

No comments:

Post a Comment