BookmarkSubscribeRSS Feed
Daily1
Quartz | Level 8

 


year revenue State 1 121286 87648 2 142947 103448 3 149822 108641 4 165415 115090 5 185036 126628 6 204693 136616 7 243654 167948 8 278996 187538 9 283190 188971 10 269468 164280 11 333311 220982 12 405678 277584 13 . .

data exam_data;
    input year total_revenue;
    datalines;
1 121286
2 142947
3 149822
4 165415
5 185036
6 204693
7 243654
8 278996
9 283190
10 269468
11 333311
12 405678
13 . 

;
run;

proc reg data = exam_data outest=rec1;
   model total_revenue = year;
     output out=forecast p=predicted;
run;

proc print data=forecast;
run;

 

I am trying to calculate the linear forecast value for 13, but I do not have the Proc Forecast procedure. That's why I'm trying Proc Reg. Please suggest how to find the forecast value of revenue and state columns separately

 

3 REPLIES 3
PaigeMiller
Diamond | Level 26

@Rick_SAS has the answer in the case of linear regression (and similar models)

 

https://blogs.sas.com/content/iml/2014/02/17/the-missing-value-trick-for-scoring-a-regression-model....

--
Paige Miller
Rick_SAS
SAS Super FREQ

>  Please suggest how to find the forecast value of revenue and state columns separately

 

Can you explain what you mean by "separately"? Do you mean that Revenue and State are both response variables, and you want to predict each of them by using a linear model that is fit to the first 12 years of those variables?  If so, just use two MODEL statements, one for Revenue and one for State.

You can do this by making two calls to PROC REG and merging the results, or (since PROC REG is an interactive procedure), by using two MODEL statements in the same call, as shown below.

 

data exam_data;
    input year Revenue State;
    datalines;
1	121286	87648
2	142947	103448
3	149822	108641
4	165415	115090
5	185036	126628
6	204693	136616
7	243654	167948
8	278996	187538
9	283190	188971
10	269468	164280
11	333311	220982
12	405678	277584
13	.	.
;
run;

proc reg data = exam_data outest=rec1;
   var revenue state year;
   model revenue = year;
   output out=forecast1 p=predRevenue;
run;
   model State = year;
   output out=forecast2 p=predState;
quit;

data forecast;
merge forecast1 forecast2;
by year;
run;

proc print data=forecast;
run;

If this is not what you want, then please explain what model you are looking for.

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 516 views
  • 0 likes
  • 4 in conversation