Chapter Contents Previous Next
 CCHART Statement

## Creating c Charts from Nonconformities per Unit

 See SHWCCHR1 in the SAS/QC Sample Library

In the previous example, the input data set provided the number of nonconformities per subgroup sample. However, in some applications, as illustrated here, the data may be provided as the number of nonconformities per inspection unit for each subgroup.

A clothing manufacturer ships shirts in boxes of ten. Prior to shipment, each shirt is inspected for flaws. Since the manufacturer is interested in the average number of flaws per shirt, the number of flaws found in each box is divided by ten and then recorded. The following statements create a SAS data set named SHIRTS, which contains the average number of flaws per shirt for 25 boxes:

```   data shirts;
input box avgdefu @@;
avgdefn=10;
datalines;
1  0.4    2  0.7    3  0.5    4  1.0   5  0.3
6  0.2    7  0.0    8  0.4    9  0.4  10  0.6
11  0.2   12  0.7   13  0.3   14  0.1  15  0.3
16  0.6   17  0.6   18  0.3   19  0.7  20  0.3
21  0.0   22  0.1   23  0.5   24  0.6  25  0.4
;
```

A listing of SHIRTS is shown in Figure 33.6.

 Average Number of Shirt Flaws

 box avgdefu avgdefn 1 0.4 10 2 0.7 10 3 0.5 10 4 1.0 10 5 0.3 10 6 0.2 10 7 0.0 10 8 0.4 10 9 0.4 10 10 0.6 10 11 0.2 10 12 0.7 10 13 0.3 10 14 0.1 10 15 0.3 10 16 0.6 10 17 0.6 10 18 0.3 10 19 0.7 10 20 0.3 10 21 0.0 10 22 0.1 10 23 0.5 10 24 0.6 10 25 0.4 10
Figure 33.6: The Data Set SHIRTS

The data set SHIRTS contains three variables: the box number (BOX), the average number of flaws per shirt (AVGDEFU), and the number of shirts per box (AVGDEFN). Here, a subgroup is a box of shirts, and an inspection unit is an individual shirt. Note that each subgroup consists of ten inspection units.

To create a c chart plotting the total number of flaws per box (instead of per shirt), you can specify SHIRTS as a HISTORY= data set.

```   title 'Total Flaws per Box of Shirts';
symbol v=dot c=red;
proc shewhart history=shirts;
cchart avgdef*box / cframe   = steel
cconect  = red
cinfill  = ligr
coutfill = yellow ;
run;
```

Note that AVGDEF is not the name of a SAS variable in the data set but is instead the common prefix for the SAS variable names AVGDEFU and AVGDEFN. The suffix characters U and N indicate number of nonconformities per unit and sample size, respectively. This naming convention enables you to specify two variables in the HISTORY= data set with a single name referred to as the process. The name BOX specified after the asterisk is the name of the subgroup-variable. The c chart is shown in Figure 33.7.

Figure 33.7: A c Chart for Boxes of Shirts

In general, a HISTORY= input data set used with the CCHART statement must contain the following variables:

• subgroup variable
• subgroup number of nonconformities per unit variable
• subgroup sample size variable

Furthermore, the names of the nonconformities per unit and sample size variables must begin with the process name specified in the CCHART statement and end with the special suffix characters U and N, respectively. If the names do not follow this convention, you can use the RENAME option to rename the variables for the duration of the SHEWHART procedure step. Suppose that, instead of the variables AVGDEFU and AVGDEFN, the data set SHIRTS contained the variables SHIRTDEF and SIZES. The following statements would temporarily rename SHIRTDEF and SIZES to AVGDEFU and AVGDEFN:

```   proc shewhart
history=shirts (rename=(shirtdef = avgdefu
sizes    = avgdefn ));
cchart avgdef*box;
run;
```