<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: How do you add spec limits, cpk to PROC SHEWHART with a by variable? in Statistical Procedures</title>
    <link>https://communities.sas.com/t5/Statistical-Procedures/How-do-you-add-spec-limits-cpk-to-PROC-SHEWHART-with-a-by/m-p/799402#M39320</link>
    <description>&lt;P&gt;If you are interested in computing Cpk across BY groups, PROC CAPABILITY will do that.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you want Cpk across BY groups and these are shown on a trend (SHEWHART) chart, I'm not aware of a way to do this. CORRECTION: you could certainly write a macro to do this.&lt;/P&gt;</description>
    <pubDate>Tue, 01 Mar 2022 18:13:42 GMT</pubDate>
    <dc:creator>PaigeMiller</dc:creator>
    <dc:date>2022-03-01T18:13:42Z</dc:date>
    <item>
      <title>How do you add spec limits, cpk to PROC SHEWHART with a by variable?</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/How-do-you-add-spec-limits-cpk-to-PROC-SHEWHART-with-a-by/m-p/799393#M39316</link>
      <description>&lt;P&gt;I have a data table that has the by variables (group_one &amp;amp; group_two) along with the upper and lower specifications (_lsl_ &amp;amp; _usl_). Looking at the SAS documentations, I see you can add a constant value to the lsl and usl options; however, I cannot get it to work using the data table columns _lsl_ and _usl_.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Is there a way to create the inset data table with the _lsl_ &amp;amp; _usl_ columns within the dataset?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Code Attempt:&lt;/STRONG&gt;&lt;/P&gt;
&lt;PRE&gt;DATA test;
INPUT id group_one $ group_two $ results _lsl_ _usl_;
DATALINES;
1 A A 1 2 4
2 A A 2 2 4
3 A A 3 2 4
4 A A 4 2 4
5 A A 5 2 4
6 B B 6 5 7
7 B B 7 5 7
8 B B 8 5 7
9 B B 9 5 7
10 B B 10 5 7
;
RUN;

PROC SHEWHART DATA=test;
	BY group_one group_two;
	IRCHART results*id / 
		lsl=_lsl_
		usl=_usl_;
	inset data = test lsl usl cp(6.4)/
		position=rm
		cshadow=black
		header="Summary Stats";
RUN;
&lt;/PRE&gt;
&lt;P&gt;&lt;STRONG&gt;Error:&lt;/STRONG&gt;&lt;/P&gt;
&lt;PRE&gt;1579  *DM Submits a SAS statement to the Program Editor, Log, or Procedure Output;
1580  dm log "OUT; CLEAR; LOG; CLEAR;" log continue;
1581  dm log 'next results; clear; cancel;' whostedit continue;
1582
1583  *Creates a new html result;
1584  ods html newfile=none;
NOTE: Writing HTML Body file: sashtml8.htm
1585
1586  DATA test;
1587  INPUT id group_one $ group_two $ results _lsl_ _usl_;
1588  DATALINES;

NOTE: The data set WORK.TEST has 10 observations and 6 variables.
NOTE: DATA statement used (Total process time):
      real time           0.01 seconds
      cpu time            0.00 seconds


1599  ;
1600  RUN;
1601
1602  PROC SHEWHART DATA=test;
1603      BY group_one group_two;
1604      IRCHART results*id /
1605          lsl=_lsl_
                  -----
                  22
                  76
ERROR 22-322: Syntax error, expecting one of the following: a numeric constant, a datetime constant, a missing value, (.
ERROR 76-322: Syntax error, statement will be ignored.
1606          usl=_usl_;
1607      inset data = test lsl usl cp(6.4)/
1608          position=rm
1609          cshadow=black
1610          header="Summary Stats";
1611  RUN;

NOTE: The SAS System stopped processing this step because of errors.
NOTE: PROCEDURE SHEWHART used (Total process time):
      real time           0.01 seconds
      cpu time            0.01 second
&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 01 Mar 2022 17:17:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/How-do-you-add-spec-limits-cpk-to-PROC-SHEWHART-with-a-by/m-p/799393#M39316</guid>
      <dc:creator>narnia649</dc:creator>
      <dc:date>2022-03-01T17:17:27Z</dc:date>
    </item>
    <item>
      <title>Re: How do you add spec limits, cpk to PROC SHEWHART with a by variable?</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/How-do-you-add-spec-limits-cpk-to-PROC-SHEWHART-with-a-by/m-p/799395#M39317</link>
      <description>&lt;PRE&gt;1602  PROC SHEWHART DATA=test;
1603      BY group_one group_two;
1604      IRCHART results*id /
1605          lsl=_lsl_
                  -----
                  22
                  76
ERROR 22-322: Syntax error, expecting one of the following: a numeric constant, a datetime constant, a missing value, (.
ERROR 76-322: Syntax error, statement will be ignored.&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;You need to provide a number after LSL=. You can't use _LSL_, that's not a number&lt;/P&gt;</description>
      <pubDate>Tue, 01 Mar 2022 17:26:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/How-do-you-add-spec-limits-cpk-to-PROC-SHEWHART-with-a-by/m-p/799395#M39317</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2022-03-01T17:26:20Z</dc:date>
    </item>
    <item>
      <title>Re: How do you add spec limits, cpk to PROC SHEWHART with a by variable?</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/How-do-you-add-spec-limits-cpk-to-PROC-SHEWHART-with-a-by/m-p/799399#M39318</link>
      <description>Thanks, yeah, I was able to gather that from the documentation.&lt;BR /&gt;&lt;BR /&gt;The problem is the LSL &amp;amp; USL changes with each group variable.&lt;BR /&gt;Putting in a single number wouldn't reflect the specs changing between groups.&lt;BR /&gt;Is there another method to do this then?</description>
      <pubDate>Tue, 01 Mar 2022 17:33:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/How-do-you-add-spec-limits-cpk-to-PROC-SHEWHART-with-a-by/m-p/799399#M39318</guid>
      <dc:creator>narnia649</dc:creator>
      <dc:date>2022-03-01T17:33:33Z</dc:date>
    </item>
    <item>
      <title>Re: How do you add spec limits, cpk to PROC SHEWHART with a by variable?</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/How-do-you-add-spec-limits-cpk-to-PROC-SHEWHART-with-a-by/m-p/799401#M39319</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you have SAS VIYA, you can use&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;PROC SPC&lt;/STRONG&gt;.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Use the SPECS= option on the&amp;nbsp;IRCHART Statement (behind the forward slash):&lt;/P&gt;
&lt;TABLE class="aa-tabular"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD&gt;&lt;A tabindex="0" href="https://go.documentation.sas.com/doc/en/pgmsascdc/v_014/casstat/casstat_spc_syntax18.htm#casstat.spc.opt_specs" target="_blank"&gt;SPECS=&lt;/A&gt;&lt;/TD&gt;
&lt;TD&gt;Specifies an input data table that contains process specification limits and computes process capability indices&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Cheers,&lt;/P&gt;
&lt;P&gt;Koen&lt;/P&gt;</description>
      <pubDate>Tue, 01 Mar 2022 17:42:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/How-do-you-add-spec-limits-cpk-to-PROC-SHEWHART-with-a-by/m-p/799401#M39319</guid>
      <dc:creator>sbxkoenk</dc:creator>
      <dc:date>2022-03-01T17:42:07Z</dc:date>
    </item>
    <item>
      <title>Re: How do you add spec limits, cpk to PROC SHEWHART with a by variable?</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/How-do-you-add-spec-limits-cpk-to-PROC-SHEWHART-with-a-by/m-p/799402#M39320</link>
      <description>&lt;P&gt;If you are interested in computing Cpk across BY groups, PROC CAPABILITY will do that.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you want Cpk across BY groups and these are shown on a trend (SHEWHART) chart, I'm not aware of a way to do this. CORRECTION: you could certainly write a macro to do this.&lt;/P&gt;</description>
      <pubDate>Tue, 01 Mar 2022 18:13:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/How-do-you-add-spec-limits-cpk-to-PROC-SHEWHART-with-a-by/m-p/799402#M39320</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2022-03-01T18:13:42Z</dc:date>
    </item>
    <item>
      <title>Re: How do you add spec limits, cpk to PROC SHEWHART with a by variable?</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/How-do-you-add-spec-limits-cpk-to-PROC-SHEWHART-with-a-by/m-p/799404#M39322</link>
      <description>&lt;P&gt;I looked, thinking this was an obvious feature, but I don't see it in the documentation either.&amp;nbsp; Since PROC SHEWHART has a limits= input dataset, I thought it might be there, but that is only for input of process limits, not spec limits.&amp;nbsp; As&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/60547"&gt;@sbxkoenk&lt;/a&gt;&amp;nbsp;showed there is a way do this in Viya with PROC SPC, maybe you could put in a SAS ballot suggestion (&lt;A href="https://communities.sas.com/t5/SASware-Ballot-Ideas/idb-p/sas_ideas" target="_blank"&gt;https://communities.sas.com/t5/SASware-Ballot-Ideas/idb-p/sas_ideas&lt;/A&gt;) that they add a SPECS= input dataset for PROC SHEWHART.&lt;/P&gt;</description>
      <pubDate>Tue, 01 Mar 2022 18:05:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/How-do-you-add-spec-limits-cpk-to-PROC-SHEWHART-with-a-by/m-p/799404#M39322</guid>
      <dc:creator>Quentin</dc:creator>
      <dc:date>2022-03-01T18:05:02Z</dc:date>
    </item>
    <item>
      <title>Re: How do you add spec limits, cpk to PROC SHEWHART with a by variable?</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/How-do-you-add-spec-limits-cpk-to-PROC-SHEWHART-with-a-by/m-p/799412#M39324</link>
      <description>Thanks for the help. I ended up doing just as you mentioned and wrote a macro for it.</description>
      <pubDate>Tue, 01 Mar 2022 18:38:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/How-do-you-add-spec-limits-cpk-to-PROC-SHEWHART-with-a-by/m-p/799412#M39324</guid>
      <dc:creator>narnia649</dc:creator>
      <dc:date>2022-03-01T18:38:44Z</dc:date>
    </item>
    <item>
      <title>Re: How do you add spec limits, cpk to PROC SHEWHART with a by variable?</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/How-do-you-add-spec-limits-cpk-to-PROC-SHEWHART-with-a-by/m-p/799414#M39325</link>
      <description>&lt;P&gt;Per&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/10892"&gt;@PaigeMiller&lt;/a&gt;&amp;nbsp;, I wrote a macro to do this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;/* Place graphs in work directory so deleted. */
ods listing gpath="%sysfunc(getoption(work))";

*Closes html results;
ods html close;

*DM Submits a SAS statement to the Program Editor, Log, or Procedure Output;
dm log "OUT; CLEAR; LOG; CLEAR;" log continue;
dm log 'next results; clear; cancel;' whostedit continue;

*Creates a new html result;
ods html newfile=none;

DATA test;
INPUT id group_one $ group_two $ results _lsl_ _usl_;
DATALINES;
1 A A 1 2 4
2 A A 2 2 4
3 A A 3 2 4
4 A A 4 2 4
5 A A 5 2 4
6 B B 6 5 7
7 B B 7 5 7
8 B B 8 5 7
9 B B 9 5 7
10 B B 10 5 7
;
RUN;

DATA test;
	SET test;
	concat_columns = compress(cat(group_one, "_", group_two));
RUN;

PROC SQL NOPRINT;
	SELECT DISTINCT quote(trim(concat_columns))
	INTO :concat_filter SEPARATED BY "~"
	FROM test
	;
QUIT;


%MACRO loop_charts();
	%LET filter_length = %sysfunc(countw(&amp;amp;concat_filter,%str(~),mq));;
	%DO i=1 %TO &amp;amp;filter_length;

		%LET cur_cond = %scan(&amp;amp;concat_filter, &amp;amp;i, "~");	

		/* Create subset... */
		PROC SQL;
			CREATE TABLE test_subset AS
			SELECT *
			FROM test
			WHERE concat_columns IN ("&amp;amp;cur_cond")
			;
		QUIT;

		/* Grab USL &amp;amp; LSL */
		DATA null;
			SET test_subset END=LAST;

			IF LAST THEN DO;
				call symput("lsl_mac", _lsl_);
				call symput("usl_mac", _usl_);
			END;
		RUN;

		%PUT --&amp;gt; Lower Spec Limit &amp;amp;lsl_mac;

		PROC SHEWHART DATA=test_subset;
			IRCHART results*id / 
				lsl=&amp;amp;lsl_mac
				usl=&amp;amp;usl_mac;
			inset lsl="Lower Spec" usl="Upper Spec" cp(6.4)/
				position=rm
				cshadow=black
				header="Summary Stats";
		RUN;

	%END;
%MEND loop_charts;

%loop_charts();
&lt;/PRE&gt;</description>
      <pubDate>Tue, 01 Mar 2022 18:39:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/How-do-you-add-spec-limits-cpk-to-PROC-SHEWHART-with-a-by/m-p/799414#M39325</guid>
      <dc:creator>narnia649</dc:creator>
      <dc:date>2022-03-01T18:39:37Z</dc:date>
    </item>
  </channel>
</rss>

