DATA Step, Macro, Functions and more

Regression

Reply
Contributor
Posts: 25

Regression

Hi, I really need some help on the BY statement in proc reg.

 

I want to regress the impl_volatility on delta variable but I want to do so for every security same ID) on every day t (same date) for securities with the same expiry date (exdate) on that day. In a day, there are different options with different expiry dates. Therefore, I expect to have more than one slope coefficient on same date t.

 

First I sort the data with

proc sort data=A1;

by cusip exdate date;

run;

 

Second, I run the regression with:

proc reg data=A1 outest=A2;

model impl_volatility=delta;

by cusip exdate date;

run;

 

However, this  doesn't work. Can someone please help me out? Thank you.

Trusted Advisor
Posts: 1,018

Re: Regression

You didn't say what is wrong.

 

Do you really want to group by cusip/exdate/date?   Are there lots of observations with the same cusip/exdate/date for the regression to process? 

Contributor
Posts: 25

Re: Regression

The code looks okay but it doesn't work for some reason. The problem might be the small number of regressions on with the same cusip/exdate/date. On average there are 3 observations in the same group. But that is exactly what I need it to be to get my result. Is there some other way I can run this regression?
Super User
Posts: 11,343

Re: Regression

[ Edited ]

PLEASE describe how it "doesn't work". Do you get an error? No result? Unexpected result - describe what you think the expected result should be.

Provide data if you want code tested. https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-dat... shows how to turn a SAS dataset into data step code you can post so that we can duplicate your data.

 

Respected Advisor
Posts: 4,919

Re: Regression

I suspect that you actually get into a very long process because of all the graphs that proc reg is making by default (for each BY group). 

 

Try 

 

proc reg data=A1 outest=A2 plots=none;

PG
Contributor
Posts: 25

Re: Regression

Thank you all for your contribution. It is much appreciated. It turns out the code was okay and the problem was the small number of data for regression after grouping with by.

Trusted Advisor
Posts: 1,018

Re: Regression

"On average there are 3 observations in the same group. But that is exactly what I need it to be to get my result."

 

And you want 1 regression per by group?   Models won't even be estimated if the by group size does not have 2 more obs than there are independent variiables.  What  possible use would it be?

Ask a Question
Discussion stats
  • 6 replies
  • 237 views
  • 6 likes
  • 4 in conversation