Data Science Pilot Action Set

Linear and Nonlinear Correlation Analysis Using the exploreCorrelation Action

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 (SAS Viya: Machine Learning Procedures). 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 DATA step creates the reference data table mycas.dmagecr in your CAS session, keeping only the age, amount, coapp, duration, foreign, job, and good_bad variables. These statements assume that your CAS engine libref is named mycas, but you can substitute any appropriately defined CAS engine libref.

data mycas.dmagecr;
   set sampsio.dmagecr;
run;

The following statements run the exploreCorrelation action to analyze the correlation structure among the input variables. The action outputs a data table that contains the specified correlation statistics. Note that you can specify different sets of statistics for the nominal-nominal, nominal-interval (interval-nominal), and interval-interval pairs of variables. The action outputs the results of the analysis in an output data table named correlation_out.

proc cas;
   loadactionset "dataSciencePilot";
   dataSciencePilot.exploreCorrelation
                            / table     = "DMAGECR"
                              casOut    = {name    = "CORRELATION_OUT",
                                           replace = True}
                              stats = {nominalNominal={"mi", "su"},
                                       nominalInterval = {"mi", "su", "ftest"},
                                       intervalInterval = {"mi", "su", "pearson"}}
                              inputs    = {{name   = "age"},
                                           {name   = "amount"},
                                           {name   = "coapp"},
                                           {name   = "duration"},
                                           {name   = "foreign"},
                                           {name   = "job"}}
                              nominals  = {"coapp",  "foreign", "job"}
                              ;
   run;
   fetch / table = "CORRELATION_OUT";
   run;
quit;

The table parameter names the input reference data table. The casOut parameter names the output data table. The stats parameter specifies the set of correlation statistics to be computed for the three types of variable pairs: nominal-nominal, nominal-interval (interval-nominal), and interval-interval. The inputs parameter specifies that the age, amount, coapp, duration, foreign, and job variables be used as inputs. The nominals parameter specifies that the coapp, foreign, and job variables be used as nominal variables.

The CAS output table is shown in Output 11.4.1.

Output 11.4.1: Linear and Nonlinear Correlation

Results from table.fetch

Selected Rows from Table CORRELATION_OUT
_Index_FirstVariableSecondVariableTypeFTestProbFPearsonMISU
1agecoapp_ni_10.47605983740.6213674487.0.05691172340.0203743996
2ageforeign_ni_20.03776542210.8459544813.0.03662999850.0135726197
3agejob_ni_39.23115911275.0223212E-6.0.14398773470.0449737593
4amountage_ii_4..0.03271641670.1575333920.0415035709
5amountcoapp_ni_15.05206115920.0065608658.0.11171933110.033948961
6amountforeign_ni_22.50627141870.1137107593.0.0703177260.0204682618
7amountjob_ni_341.8577376061.771472E-25.0.19727478990.0559120431
8durationage_ii_4..-0.0361363740.08779978910.0254065779
9durationamount_ii_5..0.62498419830.49771544760.1435409495
10durationcoapp_ni_11.16987171280.3108324871.0.0228661070.0113106304
11durationforeign_ni_219.4311164480.000011559.0.04010582480.0210146317
12durationjob_ni_316.6752186851.41484E-10.0.07046592130.0290523974
13foreigncoapp_nn_1...0.00736586060.01921124
14jobcoapp_nn_1...0.01211465540.012413386
15jobforeign_nn_2...0.00725767680.0088412863


Linear and Nonlinear Correlation Analysis Using the exploreCorrelation Action

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 dmagecr data to the comma-separated-value (CSV) file dmagecr.csv and then use the following code to load the CSV file into CAS:

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

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

The following statements run the exploreCorrelation action to analyze the correlation structure among the input variables. The action outputs a data table that contains the specified correlation statistics. Note that you can specify different sets of statistics for the nominal-nominal, nominal-interval (interval-nominal), and interval-interval pairs of variables. The action outputs the results of the analysis in an output data table named correlation_out.

s:loadactionset{actionset="dataSciencePilot"}

s:dataSciencePilot_exploreCorrelation {
                              table     = {name ="DMAGECR"},
                              casOut    = {name    = "CORRELATION_OUT",
                                           replace = True},
                              stats = {nominalNominal={"mi", "su"},
                                       nominalInterval = {"mi", "su", "ftest"},
                                       intervalInterval = {"mi", "su", "pearson"}},
                              inputs    = {{name   = "age"},
                                           {name   = "amount"},
                                           {name   = "coapp"},
                                           {name   = "duration"},
                                           {name   = "foreign"},
                                           {name   = "job"}},
                              nominals  = {"coapp",  "foreign", "job"}
}

s:fetech{table = {name = "CORRELATION_OUT"}}

The table parameter names the input reference data table. The casOut parameter names the output data table. The stats parameter specifies the set of correlation statistics to be computed for the three types of variable pairs: nominal-nominal, nominal-interval (interval-nominal), and interval-interval. The inputs parameter specifies that the age, amount, coapp, duration, foreign, and job variables be used as inputs. The nominals parameter specifies that the coapp, foreign, and job variables be used as nominal variables.

For example output from the action, see the CASL code examples.

Linear and Nonlinear Correlation Analysis Using the exploreCorrelation Action

This section contains R 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 dmagecr data to the comma-separated-value (CSV) file dmagecr.csv and then use the following code to load the CSV file into CAS:

m <- cas.read.csv(s, "dmagecr.csv", casOut=list(name="dmagecr"))

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

The following statements run the exploreCorrelation action to analyze the correlation structure among the input variables. The action outputs a data table that contains the specified correlation statistics. Note that you can specify different sets of statistics for the nominal-nominal, nominal-interval (interval-nominal), and interval-interval pairs of variables. The action outputs the results of the analysis in an output data table named correlation_out.

cas.loadActionSet(s,"dataSciencePilot")

cas.dataSciencePilot.exploreCorrelation(
   s,
   table     = list(name ="DMAGECR"),
   casOut    = list(name = "CORRELATION_OUT",
                    replace = True),
   stats = list(list(nominalNominal=list("mi", "su")),
                list(nominalNominal=list("mi", "su", "ftest")),
                list(nominalNominal=list("mi", "su", "pearson"))),
   inputs    = list("age",
                    "amount",
                    "coapp",
                    "duration",
                    "foreign",
                    "job"),
   nominals  = list("coapp",
                    "foreign",
                    "job")
)

cas.fetch(s, table = list(name = "CORRELATION_OUT"))

The table parameter names the input reference data table. The casOut parameter names the output data table. The stats parameter specifies the set of correlation statistics to be computed for the three types of variable pairs: nominal-nominal, nominal-interval (interval-nominal), and interval-interval. The inputs parameter specifies that the age, amount, coapp, duration, foreign, and job variables be used as inputs. The nominals parameter specifies that the coapp, foreign, and job variables be used as nominal variables.

For example output from the action, see the CASL code examples.

Linear and Nonlinear Correlation Analysis Using the exploreCorrelation Action

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 dmagecr data to the comma-separated-value (CSV) file dmagecr.csv and then use the following code to load the CSV file into CAS:

s.upload_file('dmagecr.csv')

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

The following statements run the exploreCorrelation action to analyze the correlation structure among the input variables. The action outputs a data table that contains the specified correlation statistics. Note that you can specify different sets of statistics for the nominal-nominal, nominal-interval (interval-nominal), and interval-interval pairs of variables. The action outputs the results of the analysis in an output data table named correlation_out.

s.loadactionset(actionset="dataSciencePilot")
s.dataSciencePilot.exploreCorrelation(
     table     = {"name" : "DMAGECR"},
     casOut    = {"name" : "CORRELATION_OUT", "replace" : True},
     stats = {"nominalNominal":["mi", "su"],
              "nominalInterval":["mi", "su", "ftest"],
              "intervalInterval":["mi", "su", "pearson"]},
     inputs    = ["age", "amount", "coapp", "duration", "foreign", "job"],
     nominals  = ["coapp", "foreign", "job"]
 )
s.fetch(table = {"name":"CORRELATION_OUT"})

The table parameter names the input reference data table. The casOut parameter names the output data table. The stats parameter specifies the set of correlation statistics to be computed for the three types of variable pairs: nominal-nominal, nominal-interval (interval-nominal), and interval-interval. The inputs parameter specifies that the age, amount, coapp, duration, foreign, and job variables be used as inputs. The nominals parameter specifies that the coapp, foreign, and job variables be used as nominal variables.

For example output from the action, see the CASL code examples.

Last updated: October 09, 2026