I want to create correlation plots with similar format with p and r inside.
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.
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
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;
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
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.
Ready to level-up your skills? Choose your own adventure.