Dear All,
Create SAS data set contain output of standard errror of slope, standard errror of intercept. output generated by proc glm.
Following is SAS code:
Data inputdata;
input x y;
datalines;
1 0.9450 0.060958
2 1.8580 0.143329
4 3.7480 0.279329
8 7.4240 0.597336
10 9.1880 0.820075
20 11.7960 8.247110
30 12.6310 17.404420
40 12.7820 27.297152
;
Run;
proc reg data=inputdata ;
model y = x;
run;
After execution of above sas code, we get sas output contain slope, intercept, se of slope, se of intercept.
how to save sas output (create SAS data set) from proc reg?
Please anyone help me?
Thanks in advance.
Best Reagrads,
Pankaj Bhangale
Add an ods output statement.
proc reg data=inputdata ;
model y = x;
ods output parameterestimates=parms;
run;
The dataset parms will have what you request.
Steve Denham
Hi,
You can either look in the documentation for PROC REG to see how it might use the OUTPUT statement or the OUT= option to create a SAS dataset from your procedure results OR you can read about the
ODS OUTPUT statement to create a SAS dataset from PROC REG output objects.
Cynthia
Thank you very much for this quick reply.Your answer is correct.
It is helpful for me in another application.
Best Regards,
Pankaj Bhangale
Add an ods output statement.
proc reg data=inputdata ;
model y = x;
ods output parameterestimates=parms;
run;
The dataset parms will have what you request.
Steve Denham
Thank you very much for this quick reply.
It is helpful for me in another application.
Best Regards,
Pankaj Bhangale
Hi,
If you want to know the dataset names of ods output, use ods trace on/listing before the stat proc. Then you can pick what you want, from output window.
Thanks,
Sunil
Dear Steve Denham,
Also I want required sum of squares.
Let Y is response variable & X is independent variable.
How to create SAS data set contain output of sum of squares like Sxx, Sxy, Syy & SST (Total sum of square) through proc reg procedure?
Please anyone help me.
Thanks in advance.
Best Regards,
Pankaj Bhangale
I believe that one way to get the calculations you are looking for is to specify the outsscp option. Take a look at: http://support.sas.com/documentation/cdl/en/statug/63033/HTML/default/viewer.htm#statug_reg_sect007....
ods output anova=inputanova;
proc reg data=sashelp.class ;
model weight=height;
run;
The dataset inputanova will contain what you required.
Ksharp
Dear Ksharp,
But the dataset inputanova does not contain Sxx & Sxy.
Slope_Hat =(Sxy/Sxx)
Slope ~ N(Slope_Hat, Sigma^2/Sxx)
I want Sxy & Sxx for above application.
Best Regards
Pankaj Bhangale
Oh.....
For corrected sum of squares for x or y, You can use proc means with css option to get.
But for corrected cross product,I am afraid that you need to calculated by hand.
proc means noprint data=sashelp.class; var weight height; output out=Sxx(drop=_:) css=weight_css height_css mean=weight_mean height_mean; run; data class; set sashelp.class; if _n_ eq 1 then set Sxx; run; proc sql ; create table Sxy_Sxx as select weight_css,height_css , sum((weight-weight_mean)*(height-height_mean))as Sxy from class; quit;
Ksharp
Thank Ksharp for quick reply. you are great.
Best Regards,
Pankaj Bhangale
KSharp and Pankaj, take a look at the reference I provided earlier in this thread, particularly regarding what is included with the outsscp option. The documentation states:
outputs a data set that contains sums of squares and crossproducts |
Yes.
Art is right. I should check documentation firstly. Sorry! Pankaj Bhangale ,You should use outsscp= option to get that.
proc reg data=fitness outsscp=sscp;
var Oxygen RunTime Age Weight RestPulse RunPulse MaxPulse;
proc print data=sscp;
run;
Ksharp
HaHa.
Art297.
I just found that outsscp= option gave the Uncorrected Sum of Square, not Corrected Sum of Square and
The cross product is also uncorrected .So Maybe My code is what Op want.
I am so curious that why sas can not give us Corrected Sum of Square in proc reg.
Ksharp
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.
Ready to level-up your skills? Choose your own adventure.