## How Mean Absolute Percentage Error %28MAPE%29 can be calculated in SAS miner%3F

Solved
Occasional Learner
Posts: 1

# How Mean Absolute Percentage Error %28MAPE%29 can be calculated in SAS miner%3F

We ran linear regression on our dataset. We expect the regression node to output actual as wells as predicted values.

Now we want to calculate MAPE i.e. (actual-predicted)/actual.

Is there any options in SAS miner that would give this value?

Accepted Solutions
Solution
‎07-24-2017 01:33 PM
SAS Super FREQ
Posts: 306

## Re: How Mean Absolute Percentage Error %28MAPE%29 can be calculated in SAS miner%3F

You would have to calculate this in a SAS Code node.  If you connect your Regression node to a SAS Code node, then in the SAS Code node, the data set represented by the &em_import_data macro variable contains your actual and predicted target for each obervation.  So you could do something like:

``````data calc_mape;
set &em_import_data;
mape = %EM_RESIDUAL / %EM_Target;
run;

proc means data=calc_mape sum;
var mape;
run;``````

All Replies
SAS Employee
Posts: 51

## Re: How Mean Absolute Percentage Error %28MAPE%29 can be calculated in SAS miner%3F

Hello,

mean absolute error (MAE) and mean absolute percentage error (MAPE) are not a part of standard regression output.
They are more commonly found in the output of time series forecasting (time series regression) procedures, such as the ones in SAS/ETS, SAS/HPF (Forecast Server).
MAPE is easy to compute of course but beware that the MAPE can only be computed with respect to data that are guaranteed to be strictly positive.

I bumped into this paper (but cannot give any guarantee about its quality):

Using the Mean Absolute Percentage Error for Regression Models (Arnaud de Myttenaere: first author).

https://www.elen.ucl.ac.be/Proceedings/esann/esannpdf/es2015-107.pdf

https://hal.archives-ouvertes.fr/hal-01162980/document

Koen

Solution
‎07-24-2017 01:33 PM
SAS Super FREQ
Posts: 306

## Re: How Mean Absolute Percentage Error %28MAPE%29 can be calculated in SAS miner%3F

You would have to calculate this in a SAS Code node.  If you connect your Regression node to a SAS Code node, then in the SAS Code node, the data set represented by the &em_import_data macro variable contains your actual and predicted target for each obervation.  So you could do something like:

``````data calc_mape;
set &em_import_data;
mape = %EM_RESIDUAL / %EM_Target;
run;

proc means data=calc_mape sum;
var mape;
run;``````

🔒 This topic is solved and locked.