Survey
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
USE OF THE SAS MACRO LANGUAGE IN DEVELOPING CONTROL CHART LHIITS T. P. Walker, IBM General Technology Division, East Fishkill ABSTRACT In section II, the steps leading to the development of the control chart limits are detailed. Sections III and IV contain an example as well as an annotated listing of the SAS Macros, which make up the program. Control charts are an important tool in applied statistics, especially in qualjty control. This report describes the generation of control chart limits for process data in which the limits are developed by first grouping the raw process readings into many relatively small groups and then, from this grouped data, obtaining subsets, which are stable with respect to the standard deviation and the mean. The statistical theory underlYing the generation of control chart limits both for the process mean and for the process variation is presented in Ref 2, Chapters 3 and 4. See also Ref 3, Chapters 5, 6, and 7, for an even more detailed presentation of control chart theory. An important feature of this report is the ~ demonstration of the effective use of the SA~ Macro Language in facilitating the calculations required to develop the stable subsets and the censor limits. Without the macro language capabilities, the computations would be long, tedious, and error-prone. The calculations presented in the next section and the example in the last section make use of a sample of size 9. As will be seen, the use of a specific sample size makes it possible to identify exactly the scaling factors, which are required for generating the stable sets of data and the control chart limits. It is hoped that the use of such specific values will help to clarify the presentation. An example is given, and the SAS Macros, which make up the program, are listed. I. INTRODUCTION Control charts are a well-known tool in quality control, and the development of control chart limits is also fairly well known. However, both the concept of a statistically stable set of data and the procedure for generating such a set of data are less well known. II. This section describes the generation - from a set of raw process readings - of a subset of data, which is in statistical control. There is a series of 9 steps involved in the procedure. As will be seen. some of the steps may be repeated. The sequence proceeds from generating a set of data, which is stable with respect to the standard deviation, to generating a set stable with respect to the mean, to calculation of control chart limj_ts for individual values, to generation of the subset, which is in statistical control. This paper demonstrates the use of the SAS Macro Language (Ref. 1, Chapter 15) in achieving the following objectives: A) The generation - from a set of raw data of a subset, which is statistically stable with respect to the standard deviation. B) The generation of another subset, which is statistically stable with respect to the mean. C) The development of control chart limits for individual values. D) The generation of a subset of the original raw data readings which is in statistical control. CONTROL CHART TECHNIQUES Ordinarily. a series of repetitive calculations would be required to achieve objectives A to D. Programs would have to be rerun several times. For each run, a user would make a decision based on the results of the previous run. However, the SAS Macro Language now makes it possible to carry out the computations in one job involving a series of repetitive calculations but without intervention by the user. 1) Assume that N raw process readings are available. Let variable CT denote an individual reading. Divide the N CT-values into A groups, 9 members per group, i.e., A = N/9 rounded to the nearest integer. 2) Compute statistics CTM and CTS for each of the A groups. where CTII CTS 3) the mean of the set of 9 CTs the standard deviation of the set of 9 CTs Compute MCTM and MCTS, where MCTM MCTS the mean of the set of the A CTMs the mean of the set of the A CTSs Put ULSTD and LLSTD 858 1. 761 X HeTS 0.239 X MCTS Now construct control chart limits for individual values and- generate a subset of data which is in statistical control. The factors 0.239 and 1.761 are associated with the sample size of 9 and are obtained from Table B, in the Appendix of Ref (2). 4) 5) 8) From the A groups. delete any group whose standard deviation value CTS is greater than ULSTD or less than USTD. As a result, there will be Al groups left where Al ~ A. If Al = A. then objective A has been accomplished, i.e •• we have a set of stable groups none of whose standard deviations. CTS. falls outside the control interval (LLSTD, ULSTD). On the other hand. suppose that Al < A. Then. using the Al groups, repeat steps 3 and 4. Compute new values for MCTM. MeTS. LLSTD, and ULSTD. Next. delete from the set of Al groups those whose CTS value falls outside the new interval (LLSTD, ULSTD). As a result. there will be A2 groups left, where A2 ~ AI. If A2 = AI. then we are finished. Otherwise. repeat steps 3 and 4 using the A2 groups. At some point, there will be no more deletions. i.e •• A(K+l) = AK for some K. The control chart limits. LLCENSR, and ULCENSR implement objective C. 9) MCTS Put ULMEAN LLMEAN III. EXAMPLE (USING THE NOTATION FROM SECTION Ql 3452 384 the mean of the set of the AI< eTM's the mean of the set of the AI< CTS's 230 13 204 MCTM + 1.094 X MCTS MCTM 1.094 X MCTS 5 8656 The factor 1.094 is obtained from Table B in the Appendix of Ref (2), based on the sample size of 9. 7) From the set of N raw-process readings. delete any value CT, which falls outside the interval (LLCENSR, ULCENSR). The Nl values. which remain. represent a process. which is in control. These N1 values implement objective D. The next section presents an example of the 9-step procedure just described. The last section lists the SAS code, which implements the 9 step procedure. At this point, a set of AK groups stable with respect to the standard deviation has been obtained. Next. we develop a set stable with respect to the mean. Let MCTM the mean of the set of the BT CTM's. MCTS the mean of the set of the BT CTS's. Put ULCENSR MCTM + (3/0.9139) x MCTS LLCENSR MCTM (3/0.9139) x MCTS As with the other factors. 0.9139 is associated with the sample size of 9 and is obtained from Table B in the Appendix of Ref. (2) (Note: If all groups are deleted. then the process is totally out of control. We exclude this possibility) 6) Let MCTM 974 9265 604 From the AK group. delete any groups whose mean value CTM falls outside the internal (LLMEAN, ULMEAN). There will be B1 groups left where B1 $ AK. If B1 = AK. then objective B has been accomplished. Otherwise (if B1 < AK), then using the B1 groups, repeat steps 6 and 7. 11248 7282 2915 As before, at some point there will be no more deletions. i.e., B(T + 1) = BT for some T. The BT groups are stable with respect to the mean. By construction, they are a subset of the AK groups. which were stable with respect to the standard deviation. Hence, the BT groups are also stable with respect to the standard deviation. Thus, objectives A and B have been accomplished. 8656 1421 9167 672 859 N = Number of process readings (3452/9) A = Initial number of groups AK = Set of groups stable with respect to the standard deviation K = Number of iterations required BT = Set of groups stable with respect to the mean T = Number of iterations required MCTM value for the initial set of 384 groups MCTS value for the 384 groups MCTM value for stabilized set of 204 groups MCTS value for stabilized set of 204 groups m,CENSR Upper control chart limit for individual values LLCENSR Lower control chart limit for individual values N1 Subset of the original set these values represent a process in statistical control Mean value of CT for the original set of 3452 readings Standard deviation of CT for the original set Mean value of CT for the subset of 2915 Standard deviation of CT for this subset of 2915. ~' IV. IF LLCENSR < CT < ULCENSR; DATA KEEPER.WOOlN, SET 14; ~"T4 IS THE CENSORED, UNGROUPED DATA. SAVE IT IN A SAS DATASET; PROC MEANS DUA=H; VAR CT, TITlEI STATISTICS FOR PROCESS COUHT DATA' lIlLE2 USIHG UNGROUPED, CENSORED DATA; HOC CHART DUA"BASEI, HBAR CT; TITlE! eAR CHART OF PROCESS COUNTS FOR ORIGINAL DATA -UNGROUP ED: TITlE~ AND UNCENSORED; PROC CHART DATA=14; HBAR CT; TInH BAR CHART OF PROCESS COUHTS FOR ORIGINAl DATA -UNGROUPED; TITlEZ AND CENSORED; PRD~ COHTENTS DATA=~EErER._All_ ~ODS DIRECTORY MAP; %MEND CENSOR; SAS CODE FOR PROGRAM The program consists of a main calling routine and 4 SAS Macros: CENSOR, STABLEMN, REPEATER. AND INPUTR. The code is listed at the end of this section. Briefly. the programming sequence is as follows: 1. 2. 3. 4. Main routine calls INPUTR; INPUTR calls REPEATER; REPEATER calls STABLEMN; Main routine calls CENSOR. %MACRO STAHlEMN(ARF, TAPAl, TAPB~, 1 APB4. ~DO %WHllE (lARF < 01; %LH ~ " ~EVAl(&N+U, PROC MEANS DATA=T9 NOP~INT; VAR CTM CTS; OUTPUT OUT=U~ MEAN=MCTM MCTS; The main calling routine (lines 20500 to 21400) gets the input data, performs.8 few operations, and cal~s INPUTR. ULMEAN=MCTM+(l TAPAl~M"CTSl, ULSTD =IUPB4"MCTS: LLMEAN =MCTM- (IT AP A I"MCTS l , lLSTD "'"APB~*MCTS: OAH U4; IF _H_ = 1 THEN SET U3, END=EHDTW; iF IL'"l[AH < CTM < ULM"EAN; DATA KEEPER.5AVX36; SET ur., %*AFTER THE ITERATION IS COMPLETE, SAVX36 WIll CONTAIN THE SET OF STA8LE PROCESS DATA -GROUPED. THIS SET IS STAHE WITH RESPECT TO THE MEAN: KEEP FOBS CTM CTS; PROC MEANS DATA=n NOPRINT; VAR elM CTS; OUTPUT OUT=XTI ~"IITlCTM llTICTS; PROC MEANS DATA"U~ ~OPRIHT; VAR elM CTS; OUTPUT OUT=XT~ N=HHCTM "HCTS; DATA TBOTH2; MERGE XTl XT4, IF NllCTM ~= NHCTM The sample size of 9 and its associated scaling factors are arguments for INPUTR. These arguments are passed along to the other macros, as required. Macro INPUTR groups the data into sets of 9 (step 1 of II) and calls REPEATER. Macro REPEATER implements steps 2 to 5 of II. Notice that REPEATER will rerun until a stable set of data for the standard deviation is obtained or until the number of tries exceeds a user-defined bound (in this case, 20). When REPEATER finishes, it calls STABLEMN t which implements steps 6 and 7 of II. Like REPEATER, STABLEMN repeats until a stable set of data for the mean is obtained, or until the number of tries is exceeded. DO; TMEAN = 'NO'; H 'N > UN THEH DO; TARH = ~EVAUIN); CALL SYMPUH 'ARF' ,31: END; ElSE, END; ELSE DO, When STABLEMN is finished. control returns to the main program. which calls CENSOR. Macro CENSOR implements steps 8 and 9 of II. Additionally, a few other statistics and graphs are generated. Notice that the arguments for CENSOR are related to the sample size of 9. TMEAN SET T22, ULCENSR : MCTM + (lCAPll"MGTS): LlCENSR e MCTM - (&CAPIl"MCTSl; DATA H; IF M - 1 THEM SET H; SEl BASEl; = 'O~'; 00004700 oua04800 00005100 00005~OO 00~U5~UO oa~n5600 00005HO ~ 00 G6 a~ 0 oon06100 0000620~ OG~066~0 00006700 00006&00 00001100 OQQ07200 00007300 000076no 00007700 ooooaOOG ooon~lOo 00008400 00008500 00008700 a000B800 000091.00 ooo~noo DG009400 B000950B 000097DO 00009800 OOOlooon OOOlOlon 00010400 00010500 = ~EVAl(lHl' CALL SYMPUH'ARF',l); E~D; SET KEEPER.SA'iX56; tENO; PRDC PRINl DATA~TBOTH2; TlTLEl SIZE OF STABLE DATA SET FOR T~E MEAN, TITlE2 TKlS SOl IS A SU8SOl OF THE STABLE SET FOR SIGMA; PROC PRINT DUA=KEEPER.SAVX36; TITlEI STATISTICS FOR PROCESS COUNT DATA USING A REDUCED; 111LE2 SOl OF DHA GROUPED BY IGROUPX WHICH REPRESEN1S A STABLE; TITln PROCESS WITH RESPECT TO I~E MEAN; TITlE~ lHIS SET IS A SUBSET OF THE STABLE SET FOR SIGMA, XMEND STABLEMN, XMACRO REPEATER(ARG.ZArAI ,ZAPB,ZAPB~ ,K, lM, LSl, XDO ~WHIlE (lARG < 6), Y.lEf K " >:EVAl(&K+ll; PROC MeANS DATA=Tl NOPRlHT; VAR CTM CTS; ounUT OUT=12 MEAN=MCTM MCTS: DATA n ; SET T2; ULMEAH=MCTMH 12APA1_MCTS) ; ULSTD =&ZAPM_MCTS, llM EAN =MCTM- (!UP AI "MCTS 1 ; LlSTO "&2APB3"I"lCTS; A listing of the program code follows. nHIS IS A PROGRAM TO DEVELOP CONTROL CHART LIMITS: "THIS PROGRAM USE5 THE MACRO LANGUAGE FACHITIES OF SAS AND IS A VARIATION OF AN OLDER VERSION WHICH USED ONLY MACROS. THE MACRO LANGUAGE AlLOi<lS THE USE OF EXTENDED AND REPETITIVE DO lOOPS; ~GlOBAL GROUPX CAPAI CA?B4 ZAP~l 7.~r~~ 2APB3 CAPll .I1N LSG; ,::,ACRO CEN50R(OROUPX,CAPIll, DATA BASEl: SET KoEPER.COMPH; VCOM~6Z IS THE OnGIHAl DATA -UHGROUHD AND U~CEHSDRED; PROC MEANS DATAOBA5EI; VAR CT; TITLEI STATISTICS FOR FROCESS COUHT DATA; TITlE2 USIHG ORIGINAl DATA--UNGROUPEO, DATA Tl; SET KHPER.FlTEXZ; ;;"FITEXZ IS THE ORIGINAL DATA -GROUPED; PROC MEANS DATAoTl; VAR CTM CTS; OUTPUT OUTen MEAN=MCTM MCTS; TITlEl STATISTICS FOR PROCESS COUHT DATA: THlE2 USrNG ORIGIHAl DATA--GROUPED; DA1A Tll; SET KEEPER.SAVX16; %"SAVX36 IS THE GROUPED PROCESS DATA -STAHE WITH ~ESPECT TO THE MEAH AND SIGMA; PROC MEAHS DATA"Tll; VAR CTM CIS; OUTPUT OU1=T22 MEAN"MCTM MCIS, nTlEI STATlSnCS FOR PROCESS COUNT DUA USING A REDUCED; TlTLE2 SET OF DATA GROUPED BY &GROUPX WHICH REPRESENTS, ~!~~E~3~ STAB~E PROCESS WITH RESPECT TO THE MEAN AND SIGMA: ~,lM); 0000440G 00004500 00000100 00000200 00n00300 0~00040a n0000500 00a00600 00000100 oooonsoo 00000900 U600lUOO OOOOllOO OO~0120G unOOBOO OOOOHOO nonOl50n 00001600 00001706 OUOOIBOO 00nOl90U IF LLSTD < CTS < UlSTD; DATA HEPER.CPX6; SET H; 'I_AFTER THE ITERATION IS COMPlETE, CPX6 WILL CONTAIN THE SEl OF STABLE PROCESS DATA--GROUPED; KEEP FO&S eTM CTS; NOPRIHT, PROC MEA~S DAH"Tl VAR elM CIS: OUTPUT OU1=ZTl N=NTlCTM HHCTS; PRO~ MeANS DATA=T4 HOPRINT; VA~ C1M CTS: OUIPUT OUT"2H H=NHCTM NT4CTS, DATA TBOTH; ~G002000 00002100 ooa0220a 000023UO 00062400 OO~02500 uoua2600 000027~0 00002~0~ ~0002~00 O~OOl~~O 00U03100 OOO~3200 U0001300 000U3~00 00003500 00n03600 00001700 OOOO~~OO 00G03900 aD00400a 00G041GO 00004200 860 Oooloson 00011000 00011100 oooll~no ~0011400 00011600 OOO1l700 0001.2000 00012100 00012200 OOU12:l00 00012500 00012600 00012800 00012900 oaon~oo 00013100 00013300 0001HOO ooon500 00013700 aoonaoo OGOn9~0 ~OGHOO~ 000,4100 ~ ~ G14 2 0 0 OOOH30n 0001440G 00014500 ooa 1~600 QOG14MO 00014900 00015000 IF ~TICT5 -~ ~HCTS THE:N DD; TSIOMA = 'NO'; IF !K > HS THE:N DO; l~RK = >;EVALOK), CAlL SYMPUT('ARG',31; END; HSE; ElSE DOl r;IOMA 'OK'; ~ XEVAl(Ul; CALL SYMPUT('ARG' 3); END, DAlA n, SET KEEPER.CPH; PROC PRI~T DATA=TBOTK' TITtEl SIZE OF STABLE DATA FO~ SIGMA; PRoe PRINT DATA=KEE'P£R.CPX&' TITlE1 STATISTICS FOR PROCESS COUNT DATA USING A REDWCEP, TlTLE2 SF.J OF DATA GROWPED BY &GRGwrX WHICH R<PR£SEHT5 A STABLE, TITL!'; PROCESS WITH RESPECT TO SIGMA; 7.~CONVERGENCE FOR 5InMA-CT$--~AS BEEN OBTAINEO. NOW USING THIS STABLE SET OEVELOP A STABlE SET FOR THE MEAN--CTi'\, sn SET KoePER.epx" ~STABLEMN(-I, &1.AP~l. UAPS;,HAPB~, D,aM) %MEHD R"PEAlE~; %MACRO INPUTR( GROUPX ,CAPAI ,CAPB3 ,CAPB4 .lMN, LOG), DATA Hsn, SET B~SEF; KOBS+], FDBS=CEIl (K06S/~EVAl (IGROUPX1); GATA KEEPER.COMP6Z; SET ~ASE1' \HG~.?&Z CONTAIHS THE ORIGIHAl, UHGROUPED DATA, PROC SORT DATA=BASE1; G001520D OD0153DD aDUl5~UD GD0155DD ODOl500D UDa1570~ DDOl58DO DOOl59DO DOUl6UDO DOD L61 D~ D6Dl62UO DUUH3DO DODH4~~ ODD1650D OOU1660D U001670D OD0168DD D D~169DO DijUllUDO DOUI710U DGDI72DD DODl7HQ D~ D1 7~ 0 U ODD17SDD OD01lODD UDOl770~ UDUI7800 DnDl7900 DOO 13~DO OU01810D ODD1820D OD01830U QDD1MOU OUD1850D ODD18600 OD01870U ODnBSOD UOOlB9DD UD019CDD DOH91DO DOHnou PRDC MEAHS DATA=BASEi KOPRINT; BY fOES; VAR el; OUTPUT OUT=OUTER M[AN=CTM 5TD"CTS; DATA KEEPER.FlTEXZ; SET OUTER; \>FITEX~ CONTAINS TilE OR1GINAl DATA--GROUPED; DhTA Ti; SoT OUTER, 7.REPEATER (-1. &CAPAI, &CAPB3,&GAPH4, D ,3lM~, HSG) Y.M~ND IHPUTR, DATA BASEF (KEEP=CT DATE TYPE); SET A5H1.PlOrBOTH ASH1.PlOTTE2; TYPE = MGD{MOD(MEFAM.laDl,!O); GT=lHH FIRSTPAS*IOODO); PROC SORT DATA~BASEF; BY TYPE DATE; PROG PRINT DATA=B~SEF (O~S=~O); TITLE! F1RST ~O OBSERVATIOHS--IHPUT DATA: \lHPUl ~(9. I. U94, D .2'~ 1.761. 2D ,2D) ~C!:"SOR( 9,3.283) OD0193DD DD01940D DDOH5UD DD0196GD 000197DD aDnln~D DDOH~UD ODe200UD U002DHD DD02D20D DDU2D3ua 00020400 D D~2D5D D D~02D~U D DUU2U1DU DODZ08DO ~00209UO UUU21DUO 00 D211Q~ ODD2120U OUD2HOD OUD214UD ODD2150Q REFERENCES 1. SAS Users Guide, Basics, 1982 edition, SAS Institute Inc., Box 8000, Cary, NC 27511 2. R. C. Vaughn, Quality Control, Iowa State University Press, Ames, Iowa. 1974 3. I. loJ. Burr. Engineering Statistics and Quality Control, HcGraw-Hill, New York. 1953 TRADEMARK NOTICE .... .~ SAS is a registered trademark of the SAS Institute Inc., Cary, NC. USA. For More information, contact: Thomas p. Walker Jr. IBM Corporation. East Fishkill Facility Dept. 165. Zip 63A. Route 52 Hopewell Junction, New York 12533 914-894-5293 861