Data visualization with SAS programming

ERROR 772-580: Syntax error: expecting a constant or a dynamic

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 17
Accepted Solution

ERROR 772-580: Syntax error: expecting a constant or a dynamic

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;

;



Accepted Solutions
Solution
‎05-25-2013 03:32 PM
PROC Star
Posts: 1,143

Re: ERROR 772-580: Syntax error: expecting a constant or a dynamic

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


All Replies
Solution
‎05-25-2013 03:32 PM
PROC Star
Posts: 1,143

Re: ERROR 772-580: Syntax error: expecting a constant or a dynamic

Try circlefilled instead of closedcircle.

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

Tom

Occasional Contributor
Posts: 17

Re: ERROR 772-580: Syntax error: expecting a constant or a dynamic

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

PROC Star
Posts: 1,143

Re: ERROR 772-580: Syntax error: expecting a constant or a dynamic

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

Tom

SAS Super FREQ
Posts: 8,815

Re: ERROR 772-580: Syntax error: expecting a constant or a dynamic

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;

Occasional Contributor
Posts: 17

Re: ERROR 772-580: Syntax error: expecting a constant or a dynamic

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


SAS Super FREQ
Posts: 3,618

Re: ERROR 772-580: Syntax error: expecting a constant or a dynamic

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

SAS Super FREQ
Posts: 1,136

Re: ERROR 772-580: Syntax error: expecting a constant or a dynamic

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.

Occasional Contributor
Posts: 17

Re: ERROR 772-580: Syntax error: expecting a constant or a dynamic

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

🔒 This topic is solved and locked.

Need further help from the community? Please ask a new question.

Discussion stats
  • 8 replies
  • 1707 views
  • 3 likes
  • 5 in conversation