BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Sinistrum
Quartz | Level 8

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

 

1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

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.

 

View solution in original post

5 REPLIES 5
SteveDenham
Jade | Level 19

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

 

 

 

 

ballardw
Super User

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.

 

Sinistrum
Quartz | Level 8

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.

SteveDenham
Jade | Level 19

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

 

Steve Denham

Sinistrum
Quartz | Level 8

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

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

sas-innovate-white.png

Special offer for SAS Communities members

Save $250 on SAS Innovate and get a free advance copy of the new SAS For Dummies book! Use the code "SASforDummies" to register. Don't miss out, May 6-9, in Orlando, Florida.

 

View the full agenda.

Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 5 replies
  • 2840 views
  • 3 likes
  • 3 in conversation