BookmarkSubscribeRSS Feed
Crubal
Quartz | Level 8

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!

 

 

 

 

 

1 REPLY 1
Crubal
Quartz | Level 8

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!

 

 

 

 

 

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

How to connect to databases in SAS Viya

Need to connect to databases in SAS Viya? SAS’ David Ghan shows you two methods – via SAS/ACCESS LIBNAME and SAS Data Connector SASLIBS – in this video.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 1 reply
  • 4289 views
  • 0 likes
  • 1 in conversation