DATA Step, Macro, Functions and more

How to export result out in sas table

Reply
Occasional Contributor
Posts: 15

How to export result out in sas table

Hi everyone,

 

I have used the SAS code below to generate output result

 

proc reg data=have;
model Y=&varlist.
/ method=rsquare start=1 stop=3 noint;
quit;

S__4218911.jpg

Then, I would like to export output table into sas table to working in the next step.

Any suggestion for this?

 

Thanks for your time

Trusted Advisor
Posts: 1,837

Re: How to export result out in sas table

[ Edited ]

Try add OUTPUT optional statement to the PROC REG:

proc reg data=have;
model Y=&varlist.
/ method=rsquare start=1 stop=3 noint;
OUTPUT OUT= <sas dataset name> ; quit;

 

Occasional Contributor
Posts: 15

Re: How to export result out in sas table

No I can't get table result.

I try to run your code I get the table like this.

S__4218914.jpg

 

 

 

Trusted Advisor
Posts: 1,837

Re: How to export result out in sas table

Check more options in the documentation - 

search google by "sas proc reg documentation"

Occasional Contributor
Posts: 15

Re: How to export result out in sas table

I have tired before I asked

Super User
Posts: 13,508

Re: How to export result out in sas table


@LengYi wrote:

I have tired before I asked


Sometimes it helps to show what you actually tried.

 

Sometimes table output such as you are requesting is best put into a dataset (table is ambiguous for some of us SAS users as it might refer to a report table not data set).

This will show a generic approach to 1) identify the tables of output and 2) place one or more of them into a dataset. Since we do not have your data or macro variable definition I will use a SAS supplied data set for the example.

ods trace on;
proc reg data=sashelp.baseball;
   id name team league;
   model logSalary = nhits nruns nrbi nbb yrmajor crhits
         /method=rsquare;
quit;
ods trace off;

In the code above the ODS TRACE ON; turns on tracing of the tables generated by the following procedure(s). ODS TRACE OFF; is used to stop generating trace output.

 

The log for the above will include something similar to:

Output Added:
-------------
Name:       NObs
Label:      Number of Observations
Template:   Stat.Reg.NObs
Path:       Reg.MODEL1.Selection.logSalary.NObs
-------------

Output Added:
-------------
Name:       SubsetSelSummary
Label:      Results
Template:   Stat.REG.SubsetSelSummary
Path:       Reg.MODEL1.Selection.logSalary.SubsetSelSummary
-------------
14   quit;

Which will indicate that the second table seen in your results is the SubsetSelSummary output table. To capture that result into a data set I would add ODS OUTPUT referencing that table:

 

proc reg data=sashelp.baseball;
   id name team league;
   model logSalary = nhits nruns nrbi nbb yrmajor crhits
         /method=rsquare;
   ods output SubsetSelSummary= work.rsquares;
run;
quit;

Which will place the values of the desired table into the dataset work.rsquares.

 

Note that the output dataset will contain additional information such as the label of the model statement. If your code doesn't have any labels on the model statement(s) the output will have values for the model variable of Model1, Model2 etc. The Dependent variable of the model is included. If you have multiple models each model may have different values for the dependent variable. If using BY variables they will also be included in the output set.

Occasional Contributor
Posts: 15

Re: How to export result out in sas table

thx

Ask a Question
Discussion stats
  • 6 replies
  • 106 views
  • 0 likes
  • 3 in conversation