Help using Base SAS procedures

add p values to output dataset of proc corr

Accepted Solution Solved
Reply
Regular Contributor
Posts: 204
Accepted Solution

add p values to output dataset of proc corr

I am using this code:

 

proc sort data= SomeData;
	by SomeGroup;
run;

proc corr data=SomeData nosimple pearson spearman outp=Temp;
	var x y;
	by SomeGroup;
run;

Is there a way to get the p values into the output dataset Temp as well? I get correlations for values, which are definitely not correlated. So maybe a p value threshold could help ...


Accepted Solutions
Solution
‎01-23-2018 02:46 PM
SAS Super FREQ
Posts: 4,242

Re: add p values to output dataset of proc corr

[ Edited ]
Posted in reply to csetzkorn

As Reeza says, use ODS OUTPUT to save any statistic.  See http://support.sas.com/kb/22/848.html

Since you have BY groups, use ODS EXCLUDE to suppress the output to the screen:

 

ods exclude all;
proc corr data=SomeData;
ods output PearsonCorr=P;
	var x y;
	by SomeGroup;
run;
ods exclude none;

proc print data=P; run;

 

View solution in original post


All Replies
Super User
Posts: 23,728

Re: add p values to output dataset of proc corr

Posted in reply to csetzkorn

Aren’t P-Values in the output?

If so, use the ODS table instead, 

 

ods output pearsonCorr=want;

Regular Contributor
Posts: 204

Re: add p values to output dataset of proc corr

Thanks please adopt my original code as I do not understand. I also have the suspicion the my sas version does not produce p values.
Super User
Posts: 23,728

Re: add p values to output dataset of proc corr

Posted in reply to csetzkorn

What version of SAS are you using?

 

You add that single line of code into your proc corr procedure, exactly as is. Then a data set is created called WANT, check your log.

 

If this doesn't work, please post your log and the exact code submitted.

Solution
‎01-23-2018 02:46 PM
SAS Super FREQ
Posts: 4,242

Re: add p values to output dataset of proc corr

[ Edited ]
Posted in reply to csetzkorn

As Reeza says, use ODS OUTPUT to save any statistic.  See http://support.sas.com/kb/22/848.html

Since you have BY groups, use ODS EXCLUDE to suppress the output to the screen:

 

ods exclude all;
proc corr data=SomeData;
ods output PearsonCorr=P;
	var x y;
	by SomeGroup;
run;
ods exclude none;

proc print data=P; run;

 

☑ This topic is solved.

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

Discussion stats
  • 4 replies
  • 515 views
  • 1 like
  • 3 in conversation