another approach: data check3; infile datalines dlm=','; input defect1 defect2 defect3; datalines; 0,0,0 1,0,0 1,2,0 5,0,1 0,0,0 0,1,0 0,0,0 5,0,0 0,0,9 0,0,0 ; data temp(keep=n defect); set check3 nobs=nobs; array df(*) def:; do _n_=1 to dim(df); defect=df(_n_); if defect>0 then do; n=nobs; output; end; end; run; proc sql; create table want as select distinct defect,count(*) as total,calculated total/n as ratio from temp group by defect; quit; proc print;run; obs defect total ratio 1 1 4 0.4 2 2 1 0.1 3 5 2 0.2 4 9 1 0.1 Linlin
... View more