BookmarkSubscribeRSS Feed
deleted_user
Not applicable
I have one dependent variable y, three independent variables x1, x2, x3, and I want to creat a scatterplot matrix.
It took me several hours to try this, but still not get it...
Thank you guys.
7 REPLIES 7
Ksharp
Super User
There are lots of way to get it. and Cynthia@sas.com can do it very well.
The following code is one of these ways.

[pre]
ods graphics on;
proc corr data=sashelp.class plots=matrix;
var weight height ;
run;
ods graphics off;







proc sgscatter data=sashelp.class;
compare y=age x=(weight height);
run;
















proc sgscatter data=sashelp.class;
matrix age weight height;
run;


[/pre]



Ksharp Message was edited by: Ksharp
deleted_user
Not applicable
I have tried, but does not work. Is it because I have one more variable than your example?
Cynthia_sas
Diamond | Level 26
Hi:
Either PROC CORR or SGSCATTER will work with 3 variables, as shown in the code below, which uses SASHELP.HEART data:
[pre]

ods graphics on;
proc corr data=sashelp.heart plots=matrix;
var weight height systolic;
run;
ods graphics off;

proc sgscatter data=sashelp.heart;
compare y=ageatdeath x=(weight height systolic);
run;

proc sgscatter data=sashelp.heart;
matrix ageatdeath weight height systolic;
run;
[/pre]

Do you have SAS 9.2 and SAS/GRAPH???? If you are only running SAS 9.1.3, ODS GRAPHICS capability was still experimental in SAS 9.1.3 and SGSCATTER was not available. In SAS 9.2 the SG procedures and ODS GRAPHICS became production.

You say that you tried, but the code does not work. Can you share your program and the error message in the SAS log??? Also, for more help from graphics folks, you might consider posting this question (with code examples) in the SAS/GRAPH and ODS GRAPHICS forum.

cynthia
deleted_user
Not applicable
Thank you so much!
I am using sas 9.0, i think that is the problem.
I will try to find a sas 9.2 to try.
deleted_user
Not applicable
I got it perfectly!
Thank you. yes, we need sas 9.2.
deleted_user
Not applicable
And actually, I want to get the coefficients and means in the matrix too, could you help me with that too?
I appreciate your help so much.
Cynthia_sas
Diamond | Level 26
Hi:
I don't actually use SGSCATTER that much. I'm more of an SGPLOT person.

You might want to post your current code to the SAS/GRAPH and ODS Graphics forum and ask your question there. In the meantime, perhaps these will get you started:
http://support.sas.com/kb/37/000.html
http://support.sas.com/documentation/cdl/en/grstatproc/62603/HTML/default/viewer.htm#sgscatter-ov.ht...

In the doc link, there's an example of getting an ELLIPSE on the scatter plots with TYPE=MEAN
[pre]
matrix petallength petalwidth sepallength
/ ellipse=(type=mean)
diagonal=(histogram kernel);
[/pre]

cynthia

sas-innovate-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 7 replies
  • 2506 views
  • 0 likes
  • 3 in conversation