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

I encounted this error when using multiple scatter statements in sgplot. When I use one scatter statement, the error disapper. Anyone know what caused the problem?

Many Thanks,

CLIu



sgplot data=iop_fig;



scatter x=xvar_j y=jiop1  /  markerattrs= (symbol=circle color=black size=10);


scatter x=xvar_j y=jiop2  /  markerattrs= (symbol=closedcircle color=blue size=10);;


scatter x=xvar_j y=jiop3  /  markerattrs= (symbol=circle color=black size=10);


scatter x=xvar_j y=jiop4  /  markerattrs= (symbol=closedcircle color=blue size=10);



xaxis VALUES= (0.5 to 4.5 by .5) label = "Treatment Group and Eye" ;


yaxis VALUES= (10 to 35 by 5) label = "IOP Value (mm Hg)";



REFLINE 0.5 2.5 /AXIS=x LABEL = ("Treatment Group (N=&num_trt1.)" "Control Group (N=&num_trt2.)") ;


format xvar_j indexdf.;


run;

;


1 ACCEPTED SOLUTION

Accepted Solutions
TomKari
Onyx | Level 15

Try circlefilled instead of closedcircle.

I will cheerfully agree that this isn't the most helpful diagnostic message ever!

Tom

View solution in original post

8 REPLIES 8
TomKari
Onyx | Level 15

Try circlefilled instead of closedcircle.

I will cheerfully agree that this isn't the most helpful diagnostic message ever!

Tom

CLiu
Calcite | Level 5

Thank you. Fixed.

By the way, if i use group in one scatter statement, do you know how to set the marker attributes (open circle, closed circle and different color, etc.)?

  scatter x=xvar_j y=jiop  / group = iop ..

Thanks,

CLiu

TomKari
Onyx | Level 15

No, I can't see how we're supposed to do that. Shoot a query to tech support!

Tom

Cynthia_sas
SAS Super FREQ

Hi:

  This works to change the marker color automatically for multiple scatter plots, each with different grouping and colors coming from the style template. But, specifying a color in the markerattrs option seems to override the differing colors that normally come from the style template. So I'm thinking that if you want GROUPing in multiple scatter statements, you may need to change the style template that you use for the graph. Another reason to consult with Tech Support unless you are comfortable with style templates. Grouped data values are handled by the GDATA1-GDATA12 style elements.

cynthia

proc sgplot data=sashelp.heart;

  where cholesterol gt 300 and weight ge 125;

  title 'Group and change Marker';

  scatter x=ageatdeath y=cholesterol  /  group=sex

          markerattrs= (symbol=circle size=5) name='sc_ch';

  scatter x=ageatdeath y=weight  / group=bp_status

          markerattrs= (symbol=circlefilled size=5) name='sc_wt' y2axis;

  keylegend 'sc_ch' 'sc_wt';

run;

 

title;

CLiu
Calcite | Level 5

Thanks Cynthia

In SAS/GRAPH, this can be easily done by using 4 SYMBOL statements. But in ODS Graphics, it's not straight forward....i still prefer to use SAS/GRAPH in many cases. But I'm trying to reproduce many different types of figures i produced in SAS/GRAPH in ODS Graphics. Will post more questions later-on.

Best,

Charlie


Rick_SAS
SAS Super FREQ

You can use the DATTRMAP= option on the PROC SGPLOT statement to define a discrete atrribute map.

For an example, see Specify the colors of groups in SAS statistical graphics - The DO Loop

Jay54
Meteorite | Level 14

With SAS 9.3, you can use the DATTRMAP as suggested by Rick.  In this case, you can specify which group VALUE should get which marker symbol or color.

With SAS 9.2, you will need to define a new style in which you can replace the symbol and color values for GraphData1-N to the ones you want.  An easy way to do this is to use the MODSTYLE macro.  See Graphically Speaking article on this topic.

Coming with SAS 9.4 is a way to set group colors, symbols and line patterns in the procedure syntax itself.

CLiu
Calcite | Level 5

Thanks Sanjay and other experts from SAS!

I use SAS 9.3 and made it work by using the DATTRMAP= option suggested by Rick, but would like to see it easily done in SAS 9.4.

CHarlie

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
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
  • 8 replies
  • 5589 views
  • 3 likes
  • 5 in conversation