I have a data set that includes severl "defect" columns. Up to three defects can be recorded in each row. I'm struggling to write code that will give me a summary of occurrances of all "defects". For example, take the following data: 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 There are 10 rows. Defect number 1 (one) occurs 4 times (40%), defect 2 occurs 1 time (10%), defect 5 occurs 2 times (20%). I've put together some SAS code that will summarize one column. I'm having trouble figuring out how to do this for defects in multiple columns. I also want to add a textual discription of each defect to the output table but I want to get the numbers correct first. Here is some working sample code. Can anyone steer me in the right direction? %let nanimals=10; 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 ; proc sort; by defect1; proc summary data=check3; by defect1; where ((defect1>0 and defect1<20) or (defect2>0 and defect2<20) or (defect3>0 and defect3<20)); var defect2 defect3; output out=check1 sum=defect2 defect3 n=total; data check2; set check1; percent=100*total/&nanimals; format percent 5.1; proc print noobs; var total percent; title Defect Summary; run;
... View more