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;
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
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;
No I can't get table result.
I try to run your code I get the table like this.
Check more options in the documentation -
search google by "sas proc reg documentation"
I have tired before I asked
@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.
thx
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 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.
Ready to level-up your skills? Choose your own adventure.