Please refer data below
Customer1 | Customer2 | Customer3 | Customer4 | Customer5 | |
Jan-18 | $5,000 | $8,000 | $5,250 | $6,125 | $3,000 |
Feb-18 | $5,100 | $8,300 | $5,500 | $6,625 | $3,050 |
Mar-18 | $5,200 | $8,600 | $5,750 | $7,125 | $3,100 |
Apr-18 | $5,300 | $8,900 | $6,000 | $7,625 | $3,150 |
May-18 | $5,400 | $9,200 | $6,250 | $8,125 | $3,200 |
Jun-18 | $5,500 | $9,500 | $6,500 | $8,625 | $3,250 |
Jul-18 | $5,600 | $9,800 | $6,750 | $9,125 | $3,300 |
Aug-18 | $5,700 | $10,100 | $7,000 | $9,625 | $3,350 |
Sep-18 | $5,800 | $10,400 | $7,250 | $10,125 | $3,400 |
Oct-18 | $5,900 | $10,700 | $7,500 | $10,625 | $3,450 |
Nov-18 | $6,000 | $11,000 | $7,750 | $11,125 | $3,500 |
Dec-18 | $6,100 | $11,300 | $8,000 | $11,625 | $3,550 |
For each customer, I am trying to create a curve that fits the past 12 months of data. Essentially, if it is a Polynomial fit (Y = Ax^2+Bx+C ), I am looking for coefficients A,B, C & the error ( MSE or RMSE etc..).
I have used Proc Orthoreg/Reg etc.. to get the results but, this will alow me to do this for 1 account at a time. If I am dealing with large volume of accts, this is not an option at all. So, I don't think I can use SAS procedures for this.
Is/Are there function(s) available in SAS that allows me to do that. I am looking for something similar to the "Polyfit" function in Python.
If not, is there a way to achieve the same results using SAS?
Thanks
You don't really indicate which variable is X and which variable is Y is in this data, so could you please clarify this?
In general, a polynomial function is fit through PROC GLM (although there are many other PROCs that will do this as well). Example:
proc glm data=have;
model y = x x*x;
run;
quit;
I added example code to my first reply. That should give you enough information to do this.
Paige,
Thanks for the response.
I have used Proc Orthoreg/Reg etc.. to get the results (Coefficients for the Polynomial equation), 1 account at a time. I think PROC GLM would work the same way. In the sample table I had provided, I would have to create separate SAS dataset for each customer and use PROC GLM for each of those datasets. If I am dealing with large volume of accts, this is not an option at all. So, I don't think I can use SAS PROC for this. Please correct me if I misunderstood how Proc GLM would work.
I think a SAS Function would be the way to go. Let me know your thoughts.
Thanks.
Siva
@siva5578 wrote:
In the sample table I had provided, I would have to create separate SAS dataset for each customer and use PROC GLM for each of those datasets.
No, one data set works fine.
If I am dealing with large volume of accts, this is not an option at all. So, I don't think I can use SAS PROC for this. Please correct me if I misunderstood how Proc GLM would work.
Sure it works if you follow these instructions: https://blogs.sas.com/content/iml/2017/02/13/run-1000-regressions.html
What is your dependent variable here?
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
Check out this tutorial series to learn how to build your own steps in SAS Studio.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.