proc contents data=&_valid; data next; set &_valid; keep leaf occupatn class id; id = (class=">50K"); leaf = _1_ + 2*_2_ + 3*_3_ + 4*_4_ + 5*_5_; proc sort data=next; by leaf; proc means nway noprint; var id; class occupatn; id leaf; output out=out1 mean=pct; proc sort data=out1; by pct; proc print data=out1; proc freq data=next; tables leaf*class/chisq nopct norow nocol; tables occupatn*class / chisq nopct norow nocol; run;