//ADMCPSAMP JOB (IX040000,8506),SAS,MSGCLASS=H,NOTIFY=&SYSUID //S1 EXEC SAS93 //PDB DD DSN=MXG.TYPE30V.SAMPDATA,DISP=SHR //SYSIN DD * options ls=72; options nofmterr nocenter source source2; LIBNAME PDB 'c:\project\$data\'; *PC ONLY; Title 'Control Chart Workshop'; *These are the variable to keep * THING, you are interested in System/Task in this example * DATETIMEVAR, 15min in this example also coverted to datehour, date * IVAR, the Interest VARiable which is cputm in this example * TIMEGROUP, optional groups of time which can be used to create separate charts by weekday shift weekday_hour etc ; data detail (keep=thing datetimevar timegroup ivar datatime datehour date hour); format date weekdate15. datehour DATETIME10.; label thing = 'System/Task' timegroup = 'Shift' datetimevar = 'date' ivar = 'CPU Time' ; *This is MXG started task data from the pdb.type30_v * (or pdb.smfintrv) for this example; SET PDB.type30_v (keep=system job typetask synctime cputm where=(typetask eq 'STC')) ; *Setup all needed Time based variables; datatime = floor(synctime-60); date = DATEPART(datatime); hour = hour(datatime); datehour = dhms(date,hour,0,0); weekday=weekday(date); if hour ge 8 and hour le 16 then shift = 1; if hour ge 17 and hour le 23 then shift = 2; if hour ge 0 and hour le 7 then shift = 3; if weekday eq 1 or weekday eq 7 then shift = 4; *Only four variables needed from here on; thing = system||' '||job; ivar = cputm; format ivar time10.; timegroup = shift; *create one datetime value for each day for example; datetimevar = date; *datetimevar = dhms(date,hour,0,0); format datetimevar weekdate15.; proc sort data=detail; by thing timegroup datetimevar; run; *Summarize to one record for each system/task, date, * and shift for CPUTM in this example; proc means data=detail noprint; by thing timegroup datetimevar; var ivar; output out=sumdata sum=ivar; run; *Summarize all data points for each thing and timegroup * and determine mean and standard deviation; proc means data=sumdata noprint; *n mean max min range std clm fw=8; *subset the control limit time period here if desired; *where datetimevar le '01may11:00:00:00'dt; by thing timegroup; var ivar; output out=control mean=ivarmean std=ivarstd ; run; *Create +/- SD data to be merged with real data for graphing; data control; set control; label ivarmean='Mean'; *determine your control limits here; UL = ivarmean + 3*ivarstd; LL = ivarmean - 3*ivarstd; run; *Merge summarized data with Control limit data; data combine; merge sumdata control; by thing timegroup; run; *Test to see if latest data point exceeded control limit; data exceptions (keep=thing timegroup); set combine; by thing timegroup; if last.timegroup and (ivar ge ul or ivar le ll); run; *Merge exception list to get all data for the exceptions; data graphdata; merge combine (in=comb) exceptions (in=except); by thing timegroup; if comb and except; run; *Create HTML and Graphs in Web directory; ods _all_ close; ods graphics on / reset=index imagename='sample' antialias=on antialiasmax=10000 ; *path='/u/mxgzfs' (url=none); *path="c:\inetpub\wwwroot\zos_stc" (url=none); ods html path="c:\inetpub\wwwroot\zos_stc" (url=none) body='sample.htm' newfile=page frame='sample_frame.htm' (TITLE='Title') contents='sample_contents.htm' ; *http://support.sas.com/resources/papers/proceedings09/158-2009.pdf; PROC SGPLOT DATA = graphdata description="Control + Data"; label datetimevar = 'Intervals'; format ivar 5.; by thing timegroup; SERIES X = datetimevar Y = ivar / break markers markerattrs=(symbol=diamondfilled); SERIES X = datetimevar Y = UL / curvelabel lineattrs=(color=red thickness=2); SERIES X = datetimevar Y = ivarmean / lineattrs=(pattern=2 thickness=2 color=green); SERIES X = datetimevar Y = LL / curvelabel lineattrs=(color=red thickness=2); XAXIS fitpolicy=rotatethin INTERVAL=day TYPE=discrete GRID ; *XAXIS fitpolicy=rotatethin; *drop INTERVAL=DAY when datetimevar is datetime vs date; TITLE 'Control Chart'; run; ods _all_ close; ods listing;