SAS Data Integration Studio, DataFlux Data Management Studio, SAS/ACCESS, SAS Data Loader for Hadoop and others

How to calculate MAPE & MSE according to two columns of data

Reply
Frequent Contributor
Posts: 118

How to calculate MAPE & MSE according to two columns of data

Hi,

 

I have a dataset with name 'Data_1' with four columns: 'Factory', 'Item', 'Date', 'Actual_Demand' & 'Prediction_Demand'.

I want to calculate MAPE and MSE that 'Prediction' via 'Actual' group by 'Factory' & 'Item' across 'Date'.

 

And my code is:

 

Proc Sql;
    Create Table Work.Result_1 as
        select distinct
            Factory,
            Item,
            avg(abs((Actual_Demand - Prediction_Demand)/Actual_Demand)) as MAPE,
            avg((Prediction_Demand - Actual_Demand)**2) as MSE
from Work.Data_1
group by 1, 2;
Quit;

 

 

So that I could obtain a new table with two new columns. Is the formula I have in the code correct to calculate 'MAPE' & 'MSE'?

 

Thank you very much!

 

 

 

 

 

Frequent Contributor
Posts: 118

MSE & MAPE Function correct?

Hi,

 

I have a dataset with name 'Data_1' with four columns: 'Factory', 'Item', 'Date', 'Actual_Demand' & 'Prediction_Demand'.

I want to calculate MAPE and MSE that 'Prediction' via 'Actual' group by 'Factory' & 'Item' across 'Date'.

 

And my code is:

 

Proc Sql;
    Create Table Work.Result_1 as
        select distinct
            Factory,
            Item,
            avg(abs((Actual_Demand - Prediction_Demand)/Actual_Demand)) as MAPE,
            avg((Prediction_Demand - Actual_Demand)**2) as MSE
        from Work.Data_1
    group by 1, 2;
Quit;

 

 

So that I could obtain a new table with two new columns. Is the formula I have in the code correct to calculate 'MAPE' & 'MSE'?

 

Thank you very much!

 

 

 

 

 

Ask a Question
Discussion stats
  • 1 reply
  • 363 views
  • 0 likes
  • 1 in conversation