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

Hi,

 

I am using proc sgscatter  with the compare statement to get three paneled scatter plots with the Y same axis, by group, and with fitted regression line:

 

proc sgscatter data=mydata
datacontrastcolors=(blue red)
datasymbols=(Square CircleFilled);
compare y=var1 
x = (var2 var3 var4) / group=var5 reg ;

run;

 

My questions:

1) When I run this code, all symbols are Squares, there are no filled circles. what should I do to customize symbols? 

2) How do I customize axes? 

   2.1) Get one single label for an X axis for all three panels. 

   2.2) Change values on one axis (something like values=(1 to 5 by 1))  and

   2.3)Fully replace values on the other axis (something like values = ("0" "1" "2")) - something I could easily do in proc gplot, but really struggle with in ods graphics. 

 

Any help would be greatly appreciated!

 

Thank you. 

    

 

1 ACCEPTED SOLUTION

Accepted Solutions
DanH_sas
SAS Super FREQ

@Rick_SAS answered #1 for you. What was happening was that the default ODS style for HTML output is HTMLBlue, which is set to be ATTRPRIORITY=COLOR. This means, in your case, that the colors must be exhausted before moving to the next symbol. By setting ATTRPRIORITY=NONE on the ODS GRAPHICS statement, you let multiple attributes change per group.

 

As for the other two items, these are items you can easily do in SGPLOT and SGPANEL, but not in SGSCATTER. The reason for this is that SGSCATTER lets you specify arbitrary plot pairs in a panel, and creating a syntax to address each possible axis in the resulting panel would start to look a lot like GTL. That being said, if you need that level of control, your best option might be to do the following:

 

1. Use the TMPLOUT option on the PROC SGSCATTER statement to dump a GTL template of your SGSCATTER request.

2. On the LAYOUT OVERLAY statements, add the TICKVALUELIST option to the LINEAROPTS options on the axis/axes you want to change (XAXISOPTS / YAXISOPTS)

3. Use that template with PROC SGRENDER to create the output.

 

Hope this helps!

Dan

View solution in original post

4 REPLIES 4
Rick_SAS
SAS Super FREQ

Here's a partial answer:

1. Use the ATTRPRIORITY=NONE option to get the symbols to change.

ods graphics / attrpriority=none;
proc sgscatter data=mydata
datacontrastcolors=(blue red)
datasymbols=(Square CircleFilled);

<etc>

run;

 

Dinurik
Fluorite | Level 6

Thank you! this worked. 

DanH_sas
SAS Super FREQ

@Rick_SAS answered #1 for you. What was happening was that the default ODS style for HTML output is HTMLBlue, which is set to be ATTRPRIORITY=COLOR. This means, in your case, that the colors must be exhausted before moving to the next symbol. By setting ATTRPRIORITY=NONE on the ODS GRAPHICS statement, you let multiple attributes change per group.

 

As for the other two items, these are items you can easily do in SGPLOT and SGPANEL, but not in SGSCATTER. The reason for this is that SGSCATTER lets you specify arbitrary plot pairs in a panel, and creating a syntax to address each possible axis in the resulting panel would start to look a lot like GTL. That being said, if you need that level of control, your best option might be to do the following:

 

1. Use the TMPLOUT option on the PROC SGSCATTER statement to dump a GTL template of your SGSCATTER request.

2. On the LAYOUT OVERLAY statements, add the TICKVALUELIST option to the LINEAROPTS options on the axis/axes you want to change (XAXISOPTS / YAXISOPTS)

3. Use that template with PROC SGRENDER to create the output.

 

Hope this helps!

Dan

DanH_sas
SAS Super FREQ

For your single label for all three axes, in your GTL template, do the following:

1. Turn off the X axis label (see the DISPLAY option)

2. Add an ENTRY to the SIDEBAR in the LAYOUT LATTICE (something like this):

SIDEBAR / align=bottom;

Entry "X label";

ENDSIDEBAR;

 

Hope this helps!

Dan

sas-innovate-wordmark-2025-midnight.png

Register Today!

Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.


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.

SAS Training: Just a Click Away

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

Browse our catalog!

Discussion stats
  • 4 replies
  • 1243 views
  • 8 likes
  • 3 in conversation