BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
lizzy28
Quartz | Level 8

Hi everyone,

 

Is there a quick way to exclude number of observations in the correlation matrix created by proc corr?

 

Thanks a lot!

 

Lizi

1 ACCEPTED SOLUTION

Accepted Solutions
art297
Opal | Level 21

Then an alternative is to modify the template that drives proc corr. e.g.:

 

ods path work.template(update) sashelp.tmplmst;
proc template;
   edit base.corr.stackedmatrix;
      column (RowName RowLabel) (Matrix) * (Matrix2) /** (Matrix3)*/ * (Matrix4);
    end;
run;
proc corr data=sashelp.cars;
run;
proc template; 
   delete base.corr.stackedmatrix;
run;

In the above code I've made a temporary template replacement for proc corr that has * (Matrix3) commented out. Since Matrix3 contains the N values, they won't appear in the output.

 

HTH,

Art, CEO, AnalystFinder.com

 

View solution in original post

6 REPLIES 6
Reeza
Super User

Can you be more specific? I can't see which N you may be referring to.

lizzy28
Quartz | Level 8
Thank you, Reeza. I'd like to have N values not shown along with correlations and pvalues. For pvalues, we can simple add NOPROB not to show pvalues. Can we do that for N?
art297
Opal | Level 21

If you're asking about the N values shown (along with correlations and pvalues) in each cell of the matrix, you can easily eliminate their appearance if you choose to exclude all cases that have any missing values. That way, the N will only show up once, above the correlation matrix.

 

That can be done by selecting the NOMISS option. e.g.:

 

proc corr data = sashelp.cars nomiss;
run;

HTH,

Art, CEO, AnalystFinder.com

 

lizzy28
Quartz | Level 8
Thanks, Art!

The only problem is that NOMISS excludes all cases with missing values. I need to keep all non-missing data for their correlations, but don't want to display the sample size in the output.
art297
Opal | Level 21

Then an alternative is to modify the template that drives proc corr. e.g.:

 

ods path work.template(update) sashelp.tmplmst;
proc template;
   edit base.corr.stackedmatrix;
      column (RowName RowLabel) (Matrix) * (Matrix2) /** (Matrix3)*/ * (Matrix4);
    end;
run;
proc corr data=sashelp.cars;
run;
proc template; 
   delete base.corr.stackedmatrix;
run;

In the above code I've made a temporary template replacement for proc corr that has * (Matrix3) commented out. Since Matrix3 contains the N values, they won't appear in the output.

 

HTH,

Art, CEO, AnalystFinder.com

 

lizzy28
Quartz | Level 8

Thanks a lot, Art!

SAS INNOVATE 2024

Innovate_SAS_Blue.png

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!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.

Get the $99 certification deal.jpg

 

 

Back in the Classroom!

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

View all other training opportunities.

Discussion stats
  • 6 replies
  • 5055 views
  • 3 likes
  • 3 in conversation