BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Jade_SAS
Pyrite | Level 9

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:

 

 

TimeCityStoreVar1Var2Var3Total # y1Total # y2Ratio(y1/y2)
 A1      
 A2      
 A3      
 B1      
 B2      
 B3      
 B4      
 C1      
 C2      
 C5      

   

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

1 ACCEPTED SOLUTION

Accepted Solutions
ptimusk
Obsidian | Level 7

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;

 

View solution in original post

2 REPLIES 2
ptimusk
Obsidian | Level 7

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;

 

Jade_SAS
Pyrite | Level 9

Thank you!

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!

Multiple Linear Regression in SAS

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.

Discussion stats
  • 2 replies
  • 944 views
  • 0 likes
  • 2 in conversation