Chapter Contents Previous Next
 UCHART Statement

## Creating u Charts from Nonconformities per Unit

 See SHWUCHR in the SAS/QC Sample Library

In the previous example, the input data set provided the number of nonconformities for each subgroup sample. However, in some applications, as illustrated here, the data provide 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
;
```

Note that this is the same data set used in "Getting Started" of Chapter 33, "CCHART Statement." A listing of SHIRTS is shown in Figure 41.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 41.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 contains ten inspection units.

To create a u chart for the average number of flaws per shirt in each box, you can specify SHIRTS as a HISTORY= data set.

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

Note that AVGDEF is not the name of a SAS variable in the data set but is, instead, the common prefix for the names of the SAS variables 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, which is referred to as the process. The name BOX, specified after the asterisk, is the name of the subgroup-variable. The u chart is shown in Figure 41.7.

Figure 41.7: A u Chart for Boxes of Shirts

In general, a HISTORY= input data set used with the UCHART 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 UCHART 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 temporarily rename SHIRTDEF and SIZES to AVGDEFU and AVGDEFN:

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