BookmarkSubscribeRSS Feed
mona4u
Lapis Lazuli | Level 10

 

I want to create correlation plots with similar format with p and r inside. 

 

mona4u_1-1651757433229.png

 

3 REPLIES 3
PaigeMiller
Diamond | Level 26

The closest that I know in SAS is the PLOTS=MATRIX option of PROC CORR. This produces the correlation value and the p-value in a table, rather than putting those values somewhere in the matrix plot, as in your graphic.

 

PaigeMiller_0-1651761030020.png

 

--
Paige Miller
Ksharp
Super User

I like this graph. Maybe @Rick_SAS  @GraphGuy  could give you a hand .or Post it at Graph forum.

 

https://communities.sas.com/t5/Graphics-Programming/bd-p/sas_graph

 

Ksharp
Super User

It is really uneasy.

Here is an example.

 

data class;
 set sashelp.class;
 array x{*} age weight height;
do i=1 to dim(x);
 do j=1 to dim(x);
   id1=vname(x{i});
   id2=vname(x{j});
   a=x{i};
   b=x{j};
   if i=j then call missing(a,b);
   corr_p='                                ';
   if i=1 and j=2 or i=2 and j=1 then corr_p='r=0.16       p=0.06';
   if i=1 and j=3 or i=3 and j=1 then corr_p='r=0.56       p=0.46';
   if i=2 and j=3 or i=3 and j=2 then corr_p='r=0.02       p=0.01';
   output;
 end;
end;
keep id1 id2 a b corr_p;
run;

proc sgpanel data=class;
panelby id1 id2/layout=lattice PROPORTIONAL   NOWALL ONEPANEL SPACING=0
COLHEADERPOS=bottom ROWHEADERPOS=left NOVARNAME NOHEADERBORDER HEADERBACKCOLOR=white ;
scatter x=a y=b;
inset corr_p/position=bottom nolabel TEXTATTRS=(size=10) ;
rowaxis display=(nolabel);
colaxis display=(nolabel);
run;

SGPanel11.png 

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

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

View all other training opportunities.

Discussion stats
  • 3 replies
  • 842 views
  • 2 likes
  • 3 in conversation