In this video, you learn will how to perform correlation analysis using SAS Studio.
From the Tasks list, click Statistics to expand the list of Statistics tasks.
Double-click the Correlations task to open it. We can make best use of our screen space by clicking the Maximize View button.
The data I am using is the Corn data set, which can be found in the documentation for the CORR procedure in SAS/STAT.
The data were collected to examine the relationship between weather and corn yield. In this example, we will investigate the relationship
that the average daily temperature of different months has on corn yield.
Click the Select a Table button on the Data tab. The data set is in the library named LIBSAS. Expand LIBSAS and select Corn. Click OK.
The screen is split. On the left side are settings for the analysis. On the right side are tabs for the code, log, and results.
You have the choice to view the settings alone or the code/results alone, or to split the screen showing both.
Right now, there is no code for the analysis because I have not assigned any variables to their roles.
Any alterations to the settings will update the code on the right. In the Roles area, you can assign variables from the Corn data set
as Analysis Variables, Correlate With, or Partial Variables. When you want to investigate the correlation between
predictor variables and a response, the predictor variables are placed in the Analysis Variables section, and the response variable is placed in
the Correlate With section. Let’s look at the relationship between monthly temperatures and corn yield.
Click the Plus button beside Analysis Variables. Select the monthly temperature variables. You can select multiple variables simultaneously by
holding down the Ctrl key and clicking the variables that you want. Click OK to assign these variables to the Analysis Variables role.
Notice that as I add variables to roles, the code on the right side is updated, reflecting the changes.
Click the Plus button beside Correlate With. Select CornYield from the list. Click OK to assign CornYield to Correlate With.
To calculate partial correlations, you can add these variables to the Partial Variables role. Expanding the Additional Roles section displays
additional roles that could be used depending on the data set. These include Frequency Count, Weight, and Group Analysis By.
After assigning variables to their respective roles, click the Options tab. In the Methods section, you can decide how to incorporate
missing values into the analysis. The Tables section contains options that enable you to
select which tables of output you want displayed. When you expand the Nonparametric Correlations section, you can
also request Spearman’s rank-order correlation, Kendall’s tau-b, and Hoeffding’s measure of dependence.
To make better use of our screen space, let’s collapse the Methods and Tables sections. For this example, let’s include individual scatter
plots that display the pairwise relationships between the predictor variables and the response.
Expand the Plots section and click the arrow beside the drop-down box for Type of plot. You can include an individual scatter plot or
a matrix of scatter plots. Let’s choose individual scatter plots. If desired, confidence or prediction ellipses can be included.
You can also add an inset that contains statistics.
Options are also available that enable you to choose the number of variables to plot as well as the maximum number of plot points.
Expanding the Output Data Set section enables you to create an output data set that you can name, containing any statistics selected with
the option to retain the original data as well. Let’s execute this task by clicking the running person icon.
To maximize our view of the output, click the Code/Results tab. Then, click Results.
The output contains all the options and graphics that were selected. Remember that CornYield was assigned to the With role, and the
temperature variables were in the Analysis role. Next we see the table containing the Pearson correlation coefficients for each
pairwise comparison of predictor and response. We did request the p-values to also be displayed, and they can be found under each
correlation coefficient. In this case, using an alpha of 0.05, July_Temp and Aug_Temp show a significant correlation with July being stronger
than August. The output concludes with the individual scatter plots for each predictor/response pairing.
The analysis can be saved with a name that you specify and then reopened later.
When you click the Exit Maximized View button, you are able to select another task, a folder, a snippet, a library, or a file shortcut.
In this video, you have learned how to use the Correlations task in SAS Studio. Now it is your turn to give it a try.