Help using Base SAS procedures

Create SAS data set from procedure reg

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 12
Accepted Solution

Create SAS data set from procedure reg

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


Accepted Solutions
Solution
‎09-08-2011 08:03 AM
Respected Advisor
Posts: 2,655

Create SAS data set from procedure reg

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

View solution in original post


All Replies
SAS Super FREQ
Posts: 8,744

Create SAS data set from procedure reg

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

Occasional Contributor
Posts: 12

Create SAS data set from procedure reg

Thank you very much for this quick reply.Your answer is correct.

It is helpful for me in another application.

Best Regards,

Pankaj Bhangale

Solution
‎09-08-2011 08:03 AM
Respected Advisor
Posts: 2,655

Create SAS data set from procedure reg

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

Occasional Contributor
Posts: 12

Create SAS data set from procedure reg

Thank you very much for this quick reply.

It is helpful for me in another application.

Best Regards,

Pankaj Bhangale

Occasional Contributor
Posts: 11

Create SAS data set from procedure reg

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

Occasional Contributor
Posts: 12

Re: Create SAS data set from procedure reg

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

PROC Star
Posts: 7,366

Re: Create SAS data set from procedure reg

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....

Super User
Posts: 9,691

Re: Create SAS data set from procedure reg

ods output anova=inputanova;

proc reg data=sashelp.class ;

model weight=height;

run;

The dataset inputanova will contain what you required.

Ksharp

Occasional Contributor
Posts: 12

Re: Create SAS data set from procedure reg

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

Super User
Posts: 9,691

Re: Create SAS data set from procedure reg

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

Occasional Contributor
Posts: 12

Re: Create SAS data set from procedure reg

Thank Ksharp for quick reply. you are great.

Best Regards,

Pankaj Bhangale

PROC Star
Posts: 7,366

Re: Create SAS data set from procedure reg

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:

OUTSSCP=

outputs a data set that contains sums of squares and crossproducts

Super User
Posts: 9,691

Re: Create SAS data set from procedure reg

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

Super User
Posts: 9,691

Re: Create SAS data set from procedure reg

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

🔒 This topic is solved and locked.

Need further help from the community? Please ask a new question.

Discussion stats
  • 17 replies
  • 1898 views
  • 3 likes
  • 6 in conversation