2
votes

Is it possible to score a data set with a model created by PROC ARIMA in SAS?

This is the code I have that is not working:

proc arima data=work.data;
identify var=x crosscorr=(y(7) y(30));
estimate outest=work.arima;
run;

proc score data=work.data score=work.arima type=parms predict out=pred;
var x;
run;

When I run this code I get an error from the PROC SCORE portion that says "ERROR: Variable x not found." The x column is in the data set work.data.

1
Can you show the data?Dinesh.hmn
You would typically use the FORECAST statement within PROC ARIMA for forecasts. Scoring a dataset is a bit different in time series data and PROC SCORE wants a linear model so I doubt this would work as expected.Reeza
@Dinesh.hmn unfortunately I can't show the data for confidentiality reasons.Jarom

1 Answers

2
votes

proc score does not support autocorrelated variables. The simplest way to get an out-of-sample score is to combine both proc arima and a data step. Here's an example using sashelp.air.

Step 1: Generate historical data

We leave out the year 1960 as our score dataset.

data have;
    set sashelp.air;
    where year(date) < 1960;
run;

Step 2: Generate a model and forecast

The nooutall option tells proc arima to only produce the 12 future forecasts.

proc arima data=have;
    identify var=air(12);
    estimate p=1 q=(2) method=ml;
    forecast lead=12 id=date interval=month out=forecast nooutall;
run;

Step 3: Score

Merge together your forecast and full historical dataset to see how well the model did. I personally like the update statement because it will not replace anything with missing values.

data want;
    update forecast(in=fcst) 
           sashelp.air(in=historical);
    by Date;

    /* Generate fit statistics */
    Error    = Forecast-Air;
    PctError = Error/Air;
    AbsPctError = abs(PctError);

    /* Helpful for bookkeeping */
    if(fcst) then Type = 'Score';
        else if(historical) then Type = 'Est';

    format PctError AbsPctError percent8.2;
run; 

You can take this code and convert it into a generalized macro for yourself. That way in the future, if you wanted to score something, you could simply call a macro program to get what you need.