05-25-2013 03:04 PM
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?
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.;
05-25-2013 03:57 PM
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 ..
05-25-2013 05:37 PM
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.
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';
05-25-2013 06:05 PM
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.
05-25-2013 06:51 PM
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
05-26-2013 11:01 AM
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.
05-26-2013 05:56 PM
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.