ASTORE Procedure
Example 4.3 Describing and Scoring with Options
This example uses the SETOPTION statement to set options when you describe and score an analytic store. It first creates an analytic store that can be used together with the SETOPTION statement, and then it uses the ASTORE procedure to describe and score the analytic store in accordance with the options that you set.
The following DATA step code creates the data table mylib.baseball by loading the baseball data set, which is available in the Sashelp library that SAS provides:
data mylib.baseball;
set sashelp.baseball;
run;
The following PROC REGSELECT call trains a GLM model on the mylib.baseball table. The model predicts the natural logarithm of a Major League Baseball player’s salary on the basis of their league, number of hits, and number of home runs. The STORE statement saves the model’s state in an analytic store, which is stored in the mylib.baseballsave table.
proc regselect data=mylib.baseball;
class league;
model logSalary = league nHome nHits;
store mylib.baseballsave;
run;
The following PROC ASTORE call sets the COMPUTE_CONFIDENCE_LIMIT option to 1 via the SETOPTION statement and then describes the contents of the analytic store via the DESCRIBE statement:
proc astore;
setoption COMPUTE_CONFIDENCE_LIMIT 1;
describe rstore=mylib.baseballsave;
quit;
Output 4.3.1 includes the following ODS tables:
The "Store Key" table displays the string identifier of the store.
The "Basic Information" table displays the analytic engine that produced the store and the time when the store was created by processing a SAVESTATE statement.
The "Input Variables" table displays the input variables.
The "Output Variables" table displays the output variables. Note that there are additional variables related to the confidence limit because the COMPUTE_CONFIDENCE_LIMIT option was set to 1.
Output 4.3.1: Output Tables from the DESCRIBE Statement
| Store Key |
|---|
| 2E6649EED53BF66EFFFD2A9A2B86AA9FD91D1984 |
| Basic Information | |
|---|---|
| Analytic Engine | glm |
| Time Created | 22May2023:14:42:16 |
| Input Variables | |||||
|---|---|---|---|---|---|
| Name | Length | Role | Type | RawType | FormatName |
| League | 8 | Input | Classification | Character | |
| nHits | 8 | Input | Interval | Num | |
| nHome | 8 | Input | Interval | Num | |
| Output Variables | |||
|---|---|---|---|
| Name | Length | Type | Label |
| P_logSalary | 8 | Num | Predicted: logSalary |
| _h_ | 8 | Num | Leverage |
| _lcl_ | 8 | Num | Lower Bound of 95% C.I.(Individual Pred) |
| _ucl_ | 8 | Num | Upper Bound of 95% C.I.(Individual Pred) |
| _lclm_ | 8 | Num | Lower Bound of 95% C.I. for Mean |
| _uclm_ | 8 | Num | Upper Bound of 95% C.I. for Mean |
| _stdi_ | 8 | Num | Standard Error of Individual Prediction |
| _stdp_ | 8 | Num | Standard Error of Mean Predicted Value |
The following PROC ASTORE call sets the ALPHA option to 0.01 and the COMPUTE_CONFIDENCE_LIMIT option to 1 via the SETOPTION statement, and then it scores the mylib.baseball table on the analytic store to produce the output data table mylib.baseballout. Note that multiple options are set using multiple SETOPTION statements. The first observation of the mylib.baseballout table is shown in Output 4.3.2. You can see the additional output variables there because the COMPUTE_CONFIDENCE_LIMIT option is set to 1, and the confidence interval values that are shown are influenced by the ALPHA option being set to 0.01.
proc astore;
setoption ALPHA 0.01;
setoption COMPUTE_CONFIDENCE_LIMIT 1;
score data=mylib.baseball
rstore=mylib.baseballsave
out=mylib.baseballout;
quit;
proc print data= mylib.baseballout (obs=1);
run;
Output 4.3.2: First Record of the Scoring Results
| Obs | P_logSalary | _h_ | _lcl_ | _ucl_ | _lclm_ | _uclm_ | _stdi_ | _stdp_ |
|---|---|---|---|---|---|---|---|---|
| 1 | 5.31435 | 0.015819 | 3.31077 | 7.31793 | 5.06432 | 5.56438 | 0.77211 | 0.096353 |