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

proc gplot is easy to have plot and plot2 to create two y axes

 

I am using 9.3.

switch to use sgplot.  2 series used different color and symbols... can you force to use same color and symbols ?

I tried goptions colors=(...) and not help.

 

this is what I have

proc sgplot data=stat ;
series y=iron x=atptn /group=trt name='iron' lineattrs=(pattern=solid) markers ;
series y=fer x=atptn /y2axis group=trt name='fer' lineattrs=(pattern=dash) markers;
xaxis label='Hour';
yaxis label='Mean Y Concentration (µg/mL)';
y2axis label='Mean Y2 Concentration (ng/mL)'; 
keylegend 'iron' /title='Dose' noborder ;
run;

1 ACCEPTED SOLUTION

Accepted Solutions
sueshaw
Obsidian | Level 7

in creating an example for you, I found out dattrmap solved the problem.

previously, I had a format for group variable...

once I remove format statement, and use raw data in attrmap and group, it worked.

this is great.... thank you...

 

another quick question... any ways to specify same symbol ? 

 

 

 

View solution in original post

10 REPLIES 10
Reeza
Super User
Which exact version of 9.3 are you using? You can check with the following code:

proc product_status;run;

There are several methods of doing this, I prefer data attribute maps because it's pretty straightforward and dynamic but there's also a STYLEATTRS statement that allows you to control the symbols/shapes/colours etc.

GOPTIONS do not apply to SG graphics.
sueshaw
Obsidian | Level 7

thank you so much.

 

for sas/graph, 9.3_M2

log file: SAS (r) Proprietary Software 9.3 (TS1M2)

 

I tried and got this msg, ERROR 180-322: Statement is not valid or it is used out of proper order.

maybe this option is not available on my version

 

proc sgplot data=stat ;
styleattrs datacolors=(red black blue green purple)
datasymbols=(circle square diamond triangle dot);
series y=iron x=atptn /group=trt name='iron' lineattrs=(pattern=solid) markers ;
series y=fer x=atptn /y2axis group=trt name='fer' lineattrs=(pattern=dash) markers;

 

Reeza
Super User

It looks like STYLEATTRS is not available for 9.3 M2, but it does look like data attribute maps are supported so that's good news. 

Here's an example of how to specify your different options. 

http://support.sas.com/documentation/cdl/en/grstatproc/65235/HTML/default/viewer.htm#n1sgstxp3pedkxn...

 

 

Here's the full documentation on attribute maps so you can specify exactly what you want. 

http://support.sas.com/documentation/cdl/en/grstatproc/65235/HTML/default/viewer.htm#p0teue0ztycuidn...

 

Hope that helps!

 


@sueshaw wrote:

thank you so much.

 

for sas/graph, 9.3_M2

log file: SAS (r) Proprietary Software 9.3 (TS1M2)

 

I tried and got this msg, ERROR 180-322: Statement is not valid or it is used out of proper order.

maybe this option is not available on my version

 

proc sgplot data=stat ;
styleattrs datacolors=(red black blue green purple)
datasymbols=(circle square diamond triangle dot);
series y=iron x=atptn /group=trt name='iron' lineattrs=(pattern=solid) markers ;
series y=fer x=atptn /y2axis group=trt name='fer' lineattrs=(pattern=dash) markers;

 


 

 

sueshaw
Obsidian | Level 7

Dear Reeza:

 

I did not get any error msgs, but the output has no impact on the new attribute.

 

thanks for your help.

Reeza
Super User
Show your code and output then.
sueshaw
Obsidian | Level 7

in creating an example for you, I found out dattrmap solved the problem.

previously, I had a format for group variable...

once I remove format statement, and use raw data in attrmap and group, it worked.

this is great.... thank you...

 

another quick question... any ways to specify same symbol ? 

 

 

 

Reeza
Super User

Same idea, add another column with the appropriate name and values and it will ensure the symbols are consistent. 

 


@sueshaw wrote:

in creating an example for you, I found out dattrmap solved the problem.

previously, I had a format for group variable...

once I remove format statement, and use raw data in attrmap and group, it worked.

this is great.... thank you...

 

another quick question... any ways to specify same symbol ? 

 

 

 


 

sueshaw
Obsidian | Level 7

I did not find document about symbol in SG attribute

 

I added a column of markersymbol to dataset attrmap,

got error msg 

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

 

I will accept with the solution to specify the color for now.

 

thank you for all of your help

DanH_sas
SAS Super FREQ

Do a PROC PRINT of your attrmap data set. You would get that error if the marker symbol name is invalid (misspelled or truncated).

sueshaw
Obsidian | Level 7

this is amazing.

 

I need to increase length for markersymbol.

I also added markercolor.

now. the outcome is exactly what I am looking for.

I have attached the output fyi.

 

thanks all for the help

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
  • 10 replies
  • 3030 views
  • 0 likes
  • 3 in conversation