MWPCA Procedure

Getting Started: MWPCA Procedure

Note: Input data must be in a CAS table that is accessible in your CAS session. You must refer to this table by using a two-level name. The first level must be a CAS engine libref, and the second level must be the table name. For more information, see the sections Using CAS Sessions and CAS Engine Librefs and Loading a SAS Data Set onto a CAS Server in Chapter 2, Shared Concepts.

The following simple example shows how to use the MWPCA procedure to monitor the operation of four wind turbines. The data, which are simulated, are the hourly energy (in kilowatts) that each turbine produces.

The following DATA step creates the Turbines data set:

   data turbines;
   input time Turbine1 Turbine2 Turbine3 Turbine4;
   datalines;
   1   3241.250445   4079.490559   3505.854227   3392.565663
   2   2395.881828   3410.130913   2783.411447   2694.114311
   3   3628.878452   4543.677282   3818.729737   3701.380754
   4   2823.608204   3806.751908   3221.480613   3029.188791
   5   3743.196614   4632.571843   3859.732421   3817.242149
   6   1807.899427   2536.174173   1698.306145   1619.159414
   7   2240.006055   3271.723656   2477.616826   2210.066151

   ... more lines ...   

The following statements plot the amount of energy that each turbine produces over time. Figure 1 shows the resulting plot.

proc sgplot data =turbines;
   series x= time y= Turbine1/legendlabel = "Turbine1" lineattrs = (thickness = 0.1);
   series x= time y= Turbine2/legendlabel = "Turbine2" lineattrs = (thickness = 0.1);
   series x= time y= Turbine3/legendlabel = "Turbine3" lineattrs = (thickness = 0.1);
   series x= time y= Turbine4/legendlabel = "Turbine4" lineattrs = (thickness = 0.1);
   yaxis label="Turbine";
run;

Figure 1: Energy Generated (Kilowatts)

Energy Generated (Kilowatts)


You can load Turbines into your CAS session by using your CAS engine libref in the first statement of the following DATA step:

   data mylib.turbines;
   set turbines;
   run;

The following statements run PROC MWPCA:

proc mwpca data=mylib.turbines windowsize=200 stepsize=1;
id time;
output out=mylib.windowpcs standardpc pcangles;
run;

Note that the STANDARDPC option is used in the OUTPUT statement. Using this option is recommended.

Figure 2 displays the "Model Information," "Dimensions," and "Results Summary" ODS tables. In the "Model Information" table, you can see the values of the WINDOWSIZE= and STEPSIZE= options and some other options that are set to their default values. A window size of 200 and step size of 1 indicates that the procedure starts with the first 200 observations in the data table, calculates the principal components, moves ahead one observation and uses observations 2–201 to calculate the principal components, and continues in this manner until the entire data table has been used.

In the "Dimensions" table, you can see the number of observations and variables in the input table. The MWPCA procedure ignores observations that have missing values; however, the ID column cannot be missing for any observation.

In the "Results Summary" table, you can see that the mylib.windowpcs data table contains 701 windows, each of which contains 200 observations. You can also see that the solution status is optimal; that is, the PCA algorithm ran successfully for all windows.

Figure 2: ODS Tables

Model Information
Data SourceTURBINES
Window Size200
Step Size1
SVD MethodEigenvalue Decomposition
Cumulative Eigenvalue Percent Tolerance1

Number of Observations900
Number of Variables4

Results Summary
Number of Windows701
Solution StatusOptimal
Run Time (Seconds)1.65


You can see the output table windowpcs in your mylib library. This table contains the elements of the first principal component for each turbine and information about how it changes over time. The following statements plot the value of the first principal component over time for each turbine. Figure 3 shows the resulting plot.

 proc sgplot data=mylib.windowpcs;
 series x=window_id y=Turbine1/legendlabel="Turbine1" lineattrs=(thickness=1);
 series x=window_id y=Turbine2/legendlabel="Turbine2" lineattrs=(thickness=1);
 series x=window_id y=Turbine3/legendlabel="Turbine3" lineattrs=(thickness=1);
 series x=window_id y=Turbine4/legendlabel="Turbine4" lineattrs=(thickness=1);
 yaxis label="First Principal Component";
 xaxis label="Window";
 run;

As you can see in Figure 3, the first principal component displays the same pattern of changes for the first three turbines. However, toward the end, the first principal component for the fourth turbine starts to behave differently from the other three turbines, indicating an abnormality in the operation of the fourth turbine.

Figure 3: First Principal Component

First Principal Component


Last updated: August 06, 2026