BookmarkSubscribeRSS Feed
kelSAS
Obsidian | Level 7

 

proc reg data=aaa noprint outest=bbb;
by year;
model y=x1 x2;
proc print data=bbb; run;

 

This gives me estimated coefficient per year, but I want to have another column with p-value next to the coefficient. Is there any way that I can do that? I used table out, but it adds rows, not columns that just complicates my reading through the output. 

 

Thank you for your reply in advance. 

4 REPLIES 4
Community_Guide
SAS Moderator

Hello @kelSAS,


Your question requires more details before experts can help. Can you revise your question to include more information? 

 

Review this checklist:

  • Specify a meaningful subject line for your topic.  Avoid generic subjects like "need help," "SAS query," or "urgent."
  • When appropriate, provide sample data in text or DATA step format.  See this article for one method you can use.
  • If you're encountering an error in SAS, include the SAS log or a screenshot of the error condition. Use the Photos button to include the image in your message.
    use_buttons.png
  • It also helps to include an example (table or picture) of the result that you're trying to achieve.

To edit your original message, select the "blue gear" icon at the top of the message and select Edit Message.  From there you can adjust the title and add more details to the body of the message.  Or, simply reply to this message with any additional information you can supply.

 

edit_post.png

SAS experts are eager to help -- help them by providing as much detail as you can.

 

This prewritten response was triggered for you by fellow SAS Support Communities member @ballardw

.
ballardw
Super User

You can use proc transpose to change rows to columns from the TABLEOUT option.

 

Or use ods output to send the displayed parameter estimates table to a data set.

proc reg data=sashelp.baseball;
   id name team league;
   model logSalary = nhits nruns nrbi nbb yrmajor crhits;
   ods output parameterestimates=work.parms;
run;

Send the variable, degrees of freedom, parameter esitmat, std err of the parameter, t value and the probT (p-vale) to the data set WORK.PARMS.

 

 

This is a very useful approach to know as some table of information are not at all accessible with any of the OUT= options and many of the newer procedures rely on this to get displayed table values into data sets. The online documentation for procedures in the details section will usually have a section of "ODS Table Names" you can reference or use the ODS TRACE ON/OFF; before after a procedure to see the names of tables generated.

kelSAS
Obsidian | Level 7

Thank you so much. I used 

 

 

 

proc reg data=aaa;
by year;
model y=x1 x2;
ods output parameterestimates=bbb;

 

 

then, to only have coefficients and p-value, I used below transpose and merge.

 

 

proc transpose data=bbb out=ccc prefix=x;
by fyear;
id variable;
var estimate;

proc transpose data=bbb out=ddd prefix=p;
by fyear;
id variable;
var probt;
run;

data ddd;
merge bbb(drop=_name_) ccc(drop=_name_);
by year;run;

proc print data=ddd;run;

 

 

This is so inefficient, but I got what I needed, so that's good, I guess.

Thank you so much for your help.

ballardw
Super User

@kelSAS wrote:

Thank you so much. I used 

 

 

 

proc reg data=aaa;
by year;
model y=x1 x2;
ods output parameterestimates=bbb;

 

 

then, to only have coefficients and p-value, I used below transpose and merge.

 

 

proc transpose data=bbb out=ccc prefix=x;
by fyear;
id variable;
var estimate;

proc transpose data=bbb out=ddd prefix=p;
by fyear;
id variable;
var probt;
run;

data ddd;
merge bbb(drop=_name_) ccc(drop=_name_);
by year;run;

proc print data=ddd;run;

 

 

This is so inefficient, but I got what I needed, so that's good, I guess.

Thank you so much for your help.


With no data I have no idea what you are building for your desired data set. I'm also confused by the use of YEAR in part of the code and FYEAR in others.

 

Proc report or proc tabulate likely can create a usable table with the BBB set directly but again without data I can't tell exactly. Something like:

proc report data=bbb;
   column fyear variable,(estimate probt);
   define fyear /group;
   define variable /across;
   define estimate/analysis;
   define probt/analysis;
run;

 

 

You might be interested to know that you can use data set options with the ODS output to only keep the variables you want such as

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!

What is ANOVA?

ANOVA, or Analysis Of Variance, is used to compare the averages or means of two or more populations to better understand how they differ. Watch this tutorial for more.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 4 replies
  • 3225 views
  • 3 likes
  • 3 in conversation