Statistical Process Control Action Set

Applying Tests for Special Causes

This section contains PROC CAS code.

Note: Input data must be accessible in your CAS session, either as a CAS table or as a transient-scope table. A CAS table has a two-level name: the first level is your CAS engine libref, and the second level is the table name. You refer to this table in the CAS procedure by specifying only the second level. For more information about two-level names, see Chapter 2, Shared Concepts. A transient-scope table is called directly from the action and exists in memory for the duration of the action. For more information about accessing data, see SAS Viya: System Programming Guide. For more information about PROC CAS and programming in CASL, see SAS Cloud Analytic Services: CASL Programmer’s Guide and SAS Cloud Analytic Services: CASL Reference.

The following statements use the mycas.Random data table from Example 26.1 and request tests for special causes in the upper X overbar analysis:

ods trace on;
proc cas;
   action spc.xChart /
      table='Random'
      exChart=true
      primaryTests={test1=true test2=true test3=true test4=true};
run;

The primaryTests parameter applies Test1–Test4 to the upper X overbar charts. Processes for which any of these tests are positive are included in the "Exception Summary" table, which is shown in Output 26.2.1.

Output 26.2.1: Results of Tests for Special Causes

Results from spc.xChart

Means Chart Summary for RANDOM
processnamesubgroupnameNumber of
Subgroups
Number
> UCL
Number
< LCL
Test 1
Signals
Test 2
Signals
Test 3
Signals
Test 4
Signals
Process006Subgroup00630011000
Process011Subgroup01130101010
Process015Subgroup01530011000
Process021Subgroup02130101000
Process031Subgroup03130000100
Process032Subgroup03230101000
Process034Subgroup03430000010
Process047Subgroup04730000020
Process048Subgroup04830000001
Process066Subgroup06630000001
Process069Subgroup06930000010
Process074Subgroup07430000001
Process078Subgroup07830011000
Process079Subgroup07930000010
Process080Subgroup08030011000
Process081Subgroup08130000010
Process089Subgroup08930101000
Process092Subgroup09230101000
Process099Subgroup09930000010


Nineteen of the 100 processes are flagged for at least one exception: a subgroup mean outside the control limits or a positive test result. Because these data were simulated from a normal distribution, they represent processes that are in statistical control. Therefore, you should regard all these exceptions as false positives.

The combined chance of a false signal when Tests 1–4 are applied together is less than 1 in 100 (see the section Interpreting Tests for Special Causes). Therefore, finding 21 exceptions in an analysis of 3,000 total subgroups is not unexpected.

Applying Tests for Special Causes

This section contains Lua code for the analysis in the CASL version of this example, which contains details about the results.

Note: In order to run this code, the data that are described in the CASL version need to be accessible to the CAS server. One way to do this is to convert the Random data to the comma-separated-value (CSV) file Random.csv and then use the following code to load the CSV file into CAS:

s:loadtable{casLib="casuser", path="Random.csv"}

For more information about coding in Lua, see Getting Started with SAS Viya for Lua and SAS Viya: System Programming Guide.

The following code loads the spc action set and then uses the xChart action to perform an upper X overbar chart analysis of the data:

s:loadactionset{actionset='spc'}
r=s:xChart{
   table='Random',
   exChart=true,
   primaryTests={test1=true,test2=true,test3=true,test4=true}}

The primaryTests parameter applies tests for special causes Test1–Test4 to the upper X overbar chart.

The following command displays the table that is produced by this action call:

r

For more information about the results of this analysis, see the CASL version of this example.

Applying Tests for Special Causes

This section contains Python code for the analysis in the CASL version of this example, which contains details about the results.

Note: In order to run this code, the data that are described in the CASL version need to be accessible to the CAS server. One way to do this is to convert the Random data to the comma-separated-value (CSV) file Random.csv and then use the following code to load the CSV file into CAS:

s.upload_file('Random.csv')

For more information about coding in Python, see Getting Started with SAS Viya for Python and SAS Viya: System Programming Guide.

The following code loads the spc action set and then uses the xChart action to perform an upper X overbar chart analysis of the data:

s.loadactionset(actionset='spc')
r=s.xChart(
   table='Random'
   exChart=true
   primaryTests=('test1':'true','test2':'true','test3:'true','test4':'true'))

The primaryTests parameter applies tests for special causes Test1–Test4 to the upper X overbar chart.

The following command displays the table that is produced by this action call:

print(r)

For more information about the results of this analysis, see the CASL version of this example.

Applying Tests for Special Causes

This example is not available for the R programming language.

Last updated: May 21, 2026