turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

Find a Community

- Home
- /
- SAS Programming
- /
- Base SAS Programming
- /
- Regression

Topic Options

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

12-02-2016 12:18 PM

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.

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to Kayomole

12-02-2016 12:31 PM

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?

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to mkeintz

12-02-2016 12:54 PM

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?

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to Kayomole

12-02-2016 12:52 PM - edited 12-09-2016 11:27 AM

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.

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to Kayomole

12-03-2016 12:05 AM

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

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to PGStats

12-08-2016 01:30 PM

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.

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to Kayomole

12-08-2016 02:14 PM

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