Solved
Contributor
Posts: 50

# Writing heteroscedasticity-consistent standard errors to OUTEST data set

[ Edited ]

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.

Yours sincerely,

Sinistrum

Accepted Solutions
Solution
‎07-01-2016 03:36 PM
Super User
Posts: 13,583

## Re: Writing heteroscedasticity-consistent standard errors to OUTEST data set

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
Posts: 2,655

## Re: Writing heteroscedasticity-consistent standard errors to OUTEST data set

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
Super User
Posts: 13,583

## Re: Writing heteroscedasticity-consistent standard errors to OUTEST data set

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.

Contributor
Posts: 50

## Re: Writing heteroscedasticity-consistent standard errors to OUTEST data set

[ Edited ]

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.

Posts: 2,655

## Re: Writing heteroscedasticity-consistent standard errors to OUTEST data set

That is OK as @ballardw's solution is much more complete than mine.

Steve Denham

Contributor
Posts: 50

## Re: Writing heteroscedasticity-consistent standard errors to OUTEST data set

[ Edited ]

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

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

☑ This topic is solved.