BookmarkSubscribeRSS Feed
Fluorite | Level 6

I am trying to use the output from a covariance matrix in an optimization model.  I want the output to look like the PROC CORR output, but instead get the output with type, obs, and name.  Is there a way to create a new dataset that matches the PROC CORR output?  If there is a altogether better way to do this, please let me know.  Thank you. 


ods select Cov PearsonCorr;
proc corr data=ret_monthly noprob outp=CovMat cov nocorr;
	var EOG_monret CAT_monret DE_monret LNG_monret GD_monret;
	Title "Covariance Matrix";

proc print data=CovMat NOOBS; 
	Title "Covariance Matrix";



Rhodochrosite | Level 12

Your other option is:

ods output pearsoncorr=p;


The data set has one set of variable for r, p, and n.  If you want to stack things to look like they do in the output, you will need to use a DATA step.

Jade | Level 19

What exactly do you mean by "a new dataset that matches the proc corr output"?  Please provide an example.

The hash OUTPUT method will overwrite a SAS data set, but not append. That can be costly. Consider voting for Add a HASH object method which would append a hash object to an existing SAS data set

Would enabling PROC SORT to simultaneously output multiple datasets be useful? Then vote for
Allow PROC SORT to output multiple datasets




Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.

If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website. 

Register now!

Multiple Linear Regression in SAS

Learn how to run multiple linear regression models with and without interactions, presented by SAS user Alex Chaplin.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 2 replies
  • 3 in conversation