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
- /
- SAS Procedures
- /
- Writing heteroscedasticity-consistent standard err...

Topic Options

- 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
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

07-01-2016 09:05 AM - edited 07-01-2016 09:06 AM

Dear community,

after getting really great help on my problem concerning utilizing iterative procedures to solve equations, now, I really would be great, if you could please help me once again.

This time, I am struggling with writing regression out to a data set.

In particular, I cannot figure out how to write heteroscedasticity-consistent standard errors to the output data set.

Assume I have a data set "regression_input" and I want to regress y on x, separated by the variable "year". Parameter estimates, standard errors, t-values and corresponding p-values (and various other statistics) are obtained in such a way:

```
proc reg data=regression_input outest=regression_output tableout noprint;
model y = x;
by year;
run;
```

If I wanted to make use of heteroscedasticity-consistent standard errors, I could let them be __displayed__ by:

```
proc reg data=regression_input outest=regression_output tableout plots(only)=none;
model y = x / hcc;
by year;
run;
```

But "tableout" will only write "standard" standard errors to my OUTEST-data set, the heteroscedasticity-consistent are only displayed in the result window.

My question is, how can I write the regression output as displayed in the "results" window, including my heteroscedasticity-consistent Standard errors, to my data set.

I would be glad, if someone could please help me.

Yours sincerely,

Sinistrum

Accepted Solutions

Solution

07-01-2016
03:36 PM

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

Posted in reply to Sinistrum

07-01-2016 01:56 PM

The generic approach to getting results window output into a dataset is ODS OUTPUT and identify the appropriate displayed table.

From the documentation for proc reg with the HCC model option I believe that the result table you want is ParameterEstimates.

So

```
proc reg data=regression_input outest=regression_output tableout plots(only)=none;
model y = x / hcc;
by year;
ods output ParameterEstimates = MyParametersDataset;
run;
```

should put all of the estimates in the dataset MyParametersDataset.

All Replies

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

Posted in reply to Sinistrum

07-01-2016 01:46 PM

Looks like a job for ODS TRACE. Try this, and see what table contains the standard errors you want. Then use ODS OUTPUT to get that table to a dataset.

```
ODS TRACE ON;
proc reg data=regression_input outest=regression_output plots(only)=none;
model y = x / hcc;
by year;
run;
ODS TRACE OFF;
```

Steve Denham

Solution

07-01-2016
03:36 PM

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

Posted in reply to Sinistrum

07-01-2016 01:56 PM

The generic approach to getting results window output into a dataset is ODS OUTPUT and identify the appropriate displayed table.

From the documentation for proc reg with the HCC model option I believe that the result table you want is ParameterEstimates.

So

```
proc reg data=regression_input outest=regression_output tableout plots(only)=none;
model y = x / hcc;
by year;
ods output ParameterEstimates = MyParametersDataset;
run;
```

should put all of the estimates in the dataset MyParametersDataset.

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

Posted in reply to ballardw

07-01-2016 02:40 PM - edited 07-01-2016 03:39 PM

So, what shall I write?

It is really awesome, how much (and quick) help I received here so far.

What you both have written is exactly what I am looking for, thank you very moch, and I have learned something I am sure I will be capable of making use of - for generally being able to writing output from the "results window" into a data set obviously is an enormous gain.

So, I use the "ODS Trace" tool in general to "bracket" my somehow-results-creating statements, to get the necessary information, the name, displayed in the log window.

Then, I include the "ODS output" piece in the statement, the output of which I was interested in in the first place, quasi pointing towards the respective "Output" and in the following, I will receive the data set I was striving for.

That is, how I understood it.

So now I have got my nice standard errors to play around with.

I am afraid, this will not have been my last question, but once again, thank you very much indeed.

---

EDIT:

I clicked to accept ballards'w answer as a solution and now am not able to accept SteveDenham's answer as a solution, too.

But de facto, they both showed me the way to tackle my problem.

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

Posted in reply to Sinistrum

07-11-2016 02:56 PM

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

Posted in reply to SteveDenham

07-11-2016 03:08 PM - edited 07-11-2016 03:08 PM

It is nice to read, that it is okay for you.

But, as I said, I appreciate both your contributions.