Hi All,
I have a data set with hierarchy City----Store, and several independent variable (var1-var3), time is daily, there is one ratio variable I'm interested to forecast (Ratio=Total # y1/ Total # y2 at that level), I have those two variables (y1, y2) in the data. I wonder whether it's possible to forecast the ratio? Thank you!
The data sample is as below:
Time | City | Store | Var1 | Var2 | Var3 | Total # y1 | Total # y2 | Ratio(y1/y2) |
A | 1 | |||||||
A | 2 | |||||||
A | 3 | |||||||
B | 1 | |||||||
B | 2 | |||||||
B | 3 | |||||||
B | 4 | |||||||
C | 1 | |||||||
C | 2 | |||||||
C | 5 |
In my understanding, we have the data of ratio (y1 and y2) at the store level and at daily frequency, but we could not use this ratio to get the weekly and city level data (which means we could not use the ratio directly for aggregation and Accumulation), we need to get the total # of y1 and total # of y2 at city level and weekly frequency, then get the ratio= total# y1/ Total# y2. Thus I don't think we can forecast the ratio at this data structure.
Please share your insight on this problem. Thank you!
Jade
This seems like an aggregate v record level ratio.
I might solve this by grouping in a summary statistic in a PROC SQL using a group by statement
like so
PROC SQL;
create table want as
select *,
sum(y1) as totalY1,
sum(y2) as totalY2,
sum(y1)/sum(y2) as RatioY1_Y2
from havedatasample
group by city, store;
quit; run;
This seems like an aggregate v record level ratio.
I might solve this by grouping in a summary statistic in a PROC SQL using a group by statement
like so
PROC SQL;
create table want as
select *,
sum(y1) as totalY1,
sum(y2) as totalY2,
sum(y1)/sum(y2) as RatioY1_Y2
from havedatasample
group by city, store;
quit; run;
Thank you!
Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.
If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website.
Learn how to run multiple linear regression models with and without interactions, presented by SAS user Alex Chaplin.
Find more tutorials on the SAS Users YouTube channel.