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

I'm trying to plot  two variables and  by using different colors/signs to plot the points belonging to three different classes.

 

Code : 

 

ods graphics / reset width=6.4in height=4.8in imagemap;

proc sgplot data=WORK.FINALWINEDATA;
scatter x=Alcohol y=Total_phenols / group=Class
markerattrs=(symbol=circlefilled size=10);
xaxis grid;
yaxis grid;
run;

ods graphics / reset;

 

But when i'm trying add more symbol, i get below error message

 

1 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
NOTE: ODS statements in the SAS Studio environment may disable some output features.
73
74
75 /* Plot the graph*/
76 ods graphics / reset width=6.4in height=4.8in imagemap;
77
78 proc sgplot data=WORK.FINALWINEDATA;
79 scatter x=Alcohol y=Total_phenols / group=Class
80 markerattrs=(symbol=circlefilled trianglefilled diamondfilled size=10);
______________
22
202
ERROR 22-322: Syntax error, expecting one of the following: ), COLOR, SIZE, SYMBOL.
ERROR 202-322: The option or parameter is not recognized and will be ignored.
81 xaxis grid;
82 yaxis grid;
83 run;
 
NOTE: The SAS System stopped processing this step because of errors.
NOTE: PROCEDURE SGPLOT used (Total process time):
real time 0.00 seconds
cpu time 0.00 seconds
 
84
85 ods graphics / reset;
86
87 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
99
1 ACCEPTED SOLUTION

Accepted Solutions
RichardDeVen
Barite | Level 11

The STYLEATTRS statement will override default color and style cycling.  

Blog entry "Attrs, attrs, everywhere: The interaction between ATTRPRIORITY, CYCLEATTRS, and STYLEATTRS in ODS g...  covers the topic in more detail.

data have;
  do x = 0 to 20 by .25;
    class = 'A';
    y = sin(x+5);
    output;
    class = 'B';
    y = 2 + 2 * sin(x/2);
    output;
    class = 'C';
    y = 6 + 3 * sin(x/1.25);
    output;
  end;
run;

ods html file='series.html';

ods graphics / attrpriority=none;

proc sgplot data=have;
  scatter x=x y=y / 
    group=class    
  ;

  styleattrs 
    datacontrastcolors = ( black red purple )
    datasymbols = ( circlefilled trianglefilled diamondfilled )
  ;
run;

ods html close;

RichardADeVenezia_0-1586673043951.png

 

View solution in original post

2 REPLIES 2
RichardDeVen
Barite | Level 11

The STYLEATTRS statement will override default color and style cycling.  

Blog entry "Attrs, attrs, everywhere: The interaction between ATTRPRIORITY, CYCLEATTRS, and STYLEATTRS in ODS g...  covers the topic in more detail.

data have;
  do x = 0 to 20 by .25;
    class = 'A';
    y = sin(x+5);
    output;
    class = 'B';
    y = 2 + 2 * sin(x/2);
    output;
    class = 'C';
    y = 6 + 3 * sin(x/1.25);
    output;
  end;
run;

ods html file='series.html';

ods graphics / attrpriority=none;

proc sgplot data=have;
  scatter x=x y=y / 
    group=class    
  ;

  styleattrs 
    datacontrastcolors = ( black red purple )
    datasymbols = ( circlefilled trianglefilled diamondfilled )
  ;
run;

ods html close;

RichardADeVenezia_0-1586673043951.png

 

learn001
Calcite | Level 5

Issue Resolved!

 

I used below refer code to fix my issue.

 

ods graphics on / attrpriority=color;
proc sgplot data=sashelp.iris aspect=1;
   scatter x=petalwidth y=sepalwidth / group=species;
   keylegend / location=outside position=right across=1;
run;

 

ods graphics on / attrpriority=none;
proc sgplot data=sashelp.iris aspect=1;
   styleattrs datasymbols=(trianglefilled circlefilled squarefilled);
   scatter x=petalwidth y=sepalwidth / group=species;
   keylegend / location=outside position=right across=1;
run;

Reference Link : https://blogs.sas.com/content/graphicallyspeaking/2018/10/08/getting-started-with-sgplot-part-13-sty...

 

Regards

Lokesh

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
  • 2 replies
  • 1031 views
  • 2 likes
  • 2 in conversation