BookmarkSubscribeRSS Feed
LengYi
Calcite | Level 5

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

6 REPLIES 6
Shmuel
Garnet | Level 18

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;

 

LengYi
Calcite | Level 5

No I can't get table result.

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

S__4218914.jpg

 

 

 

Shmuel
Garnet | Level 18

Check more options in the documentation - 

search google by "sas proc reg documentation"

LengYi
Calcite | Level 5

I have tired before I asked

ballardw
Super User

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

LengYi
Calcite | Level 5

thx

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 6 replies
  • 2856 views
  • 0 likes
  • 3 in conversation