BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
Vik_3010
Calcite | Level 5

Hello ALL.

 

Can anyone help me with excel TREND function equivalent in SAS.

 

formulae in excel is :  TREND($B$9:$S$9,$B$10:$S$10,B13,TRUE).

 

9th row is  historical %values of one variable,  10th row is historical %values of another variable and 13th row is current month value of variable.

Thank you. 

1 ACCEPTED SOLUTION

Accepted Solutions
Ksharp
Super User

I search this function at internet and found it is just a ordinal least square model(a.k.a a linear regression model).

Here could give you a start.

data train;
input y x;
cards;
1 2
2 4
3 4
5 1
2 2
;
data test;
input x;
cards;
3
5
2
5
6
;

data all;
 set train test;
run;
proc reg data=all;
model y=x;
output out=want p=pred;
quit;

proc print;run;

Ksharp_0-1749778872346.png

 

 

 

View solution in original post

3 REPLIES 3
Tom
Super User Tom
Super User

@Vik_3010 wrote:

Hello ALL.

 

Can anyone help me with excel TREND function equivalent in SAS.

 

formulae in excel is :  TREND($B$9:$S$9,$B$10:$S$10,B13,TRUE).

 

9th row is  historical %values of one variable,  10th row is historical %values of another variable and 13th row is current month value of variable.

Thank you. 


What statistic does the TREND() function in EXCEL calculate?

What is the meaning of the four arguments that you show using in your function call?

 

What are the names of the VARIABLES in your SAS dataset that you want to use as input.

Ksharp
Super User

I search this function at internet and found it is just a ordinal least square model(a.k.a a linear regression model).

Here could give you a start.

data train;
input y x;
cards;
1 2
2 4
3 4
5 1
2 2
;
data test;
input x;
cards;
3
5
2
5
6
;

data all;
 set train test;
run;
proc reg data=all;
model y=x;
output out=want p=pred;
quit;

proc print;run;

Ksharp_0-1749778872346.png

 

 

 

Vik_3010
Calcite | Level 5
Hi Ksharp.

Thanks for the solution. It worked.

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

Register Now

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

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
  • 946 views
  • 2 likes
  • 3 in conversation