BookmarkSubscribeRSS Feed
mahler_ji
Obsidian | Level 7

Hello All,

I have data that, essentially, takes the following form:

Date               var1                   var2

x/x/xx                        2                         3

x/x/xx                         2                         2

x/x/xx                    2                              1

x/x/xx                    3                              5

x/x/xx                    2                              1

and so on.  What I want to do is regress one variable on another for the previous y periods, and then have the regression beta be output as a variable in the dataset.  For example, if I picked y = 5, I would take an observation, regress var1 on var2 for the past 5 periods, and then the code would return that regression coefficient as a variable in the dataset.

I may have done a bad job explaining this, but if you have any questions, please let me know.


Thanks,

John

1 REPLY 1
Ksharp
Super User

Create a new table for that previous y periods , like :

%let y=5 ;

data temp;

merge have(keep=date var1) have(firstobs=&y keep=var2);

run;

after that proc reg data=have .

But That might be a bad idea. You'd post it at Foreasting Forum for seeking a Auto Regression Model .

Xia Keshan

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 1 reply
  • 635 views
  • 0 likes
  • 2 in conversation