BookmarkSubscribeRSS Feed
cyanezIBR
Calcite | Level 5

Hi,

I'm looking to create a scatter plot matrix with regression lines that also displays the r-squared and p value in an inset for each graph. I have tried using proc template with scatterplotmatrix, but I can only get a pearson correlation in the inset, and no regression line. I also tried proc sgscatter, but cannot get the inset to display the statistical information I need. Does anybody have any suggestions on how I can accomplish this?

Thanks

ods graphics on;

proc sgscatter data=work.query_for_stabsummarytablesfilte;

compare y=(FairnessIdxAvgTotal_Mean EqGiniVisibleTotal ) x=(GES1_SUM GES61_SUM COH4_SUM)

/ Legend=(Position=Bottom) reg=(clm nogroup) ;

Title "Group Variables";

label FairnessIdxAvgTotal_Mean="Group Fairness Idx"

  EqGiniVisibleTotal = "Equality Barrier Reveals"

   GES1_SUM = "GES:Unity"

   GES61_SUM = "GES:Proud"

   COH4_SUM = 'PCQ:Best Anywhere';

WHERE groupName = 'A' OR groupName = 'B' OR groupName = 'C' OR groupName = 'D' OR groupName = 'E';

run;

proc template;

define statgraph spminset;

begingraph;

entrytitle "Group TPT Metrics and Cohesion";

entrytitle 'Concordia 2013';

layout gridded;

scatterplotmatrix GES1_SUM GES61_SUM COH4_SUM/

  rowvars=(FairnessIdxAvgTotal_Mean EqGiniVisibleTotal)

  inset=(nobs pearson pearsonpval)

  insetopts=( border=true opaque = true)

  corropts=(nomiss=true vardef=df)

  markerattrs=(size=4px)

  ellipse=(alpha=.20 type=predicted);

endlayout;

endgraph;

end;

run;

proc sgrender data=work.query_for_stabsummarytablesfilte template=spminset;

WHERE groupName = 'A' OR groupName = 'B' OR groupName = 'C' OR groupName = 'D' OR groupName = 'E';

label FairnessIdxAvgTotal_Mean ="Group Fairness Idx"

   EqGiniVisibleTotal = "Equality Barrier Reveals"

   GES1_SUM = "GES:Unity"

   GES61_SUM = "GES:Proud"

   COH4_SUM = 'PCQ:Best Anywhere' ;

run;

ods graphics off;

4 REPLIES 4
Reeza
Super User

Here's an example of the reg line using sgscatter, not sure about the inset part.

48465 - Use an attribute map with the SGSCATTER procedure

cyanezIBR
Calcite | Level 5

yes, i was able to use SGSCATTER to create the graphs, however I'd like to have p-value and r-squared listed for each plot. It seems that SGSCATTER has no options for this.

Adie_efc
Calcite | Level 5

If the values are calculated outside, put them into macro variable and use a legend. Ive done similar for pvalues using the legend examples below

legenditem type=marker name="PValue" / LABEL="Log rank test: p=&PValue" lineattrs=GraphData1(color=black THICKNESS=10)

         labelattrs=(size=8 family="Arial") markerattrs=(size=0);

discretelegend "PValue" / titleattrs=(size=9 family="Arial")

                          BORDER=false across=1 location=inside

                          halign=left valign=bottom pad=(bottom=35);

Jay54
Meteorite | Level 14

For a small 3x3 with custom labels using GTL, you could build the matrix yourself.  That is what is happening in the background anyway.  Use a LAYOUT LATTICE with a 3x3 row-column layout, and insert the necessary scatter, reg and insets into the cells yourself.  Quite doable, especially for a small matrix.

If you want ROWVARS, you can create the appropriate combinations.  The general idea is shown in this article, but you can see what needs to be done and customize to your needs.  Compact Scatter Plot Matrix - Graphically Speaking

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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
  • 4 replies
  • 1564 views
  • 0 likes
  • 4 in conversation