BookmarkSubscribeRSS Feed
Kayomole
Calcite | Level 5

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.

6 REPLIES 6
mkeintz
PROC Star

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? 

--------------------------
The hash OUTPUT method will overwrite a SAS data set, but not append. That can be costly. Consider voting for Add a HASH object method which would append a hash object to an existing SAS data set

Would enabling PROC SORT to simultaneously output multiple datasets be useful? Then vote for
Allow PROC SORT to output multiple datasets

--------------------------
Kayomole
Calcite | Level 5
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?
ballardw
Super User

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.

 

PGStats
Opal | Level 21

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
Kayomole
Calcite | Level 5

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.

mkeintz
PROC Star

"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?

--------------------------
The hash OUTPUT method will overwrite a SAS data set, but not append. That can be costly. Consider voting for Add a HASH object method which would append a hash object to an existing SAS data set

Would enabling PROC SORT to simultaneously output multiple datasets be useful? Then vote for
Allow PROC SORT to output multiple datasets

--------------------------

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!

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
  • 6 replies
  • 1387 views
  • 6 likes
  • 4 in conversation