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

Dear All,

Need help.  How to choose symbols, such as circle for trt 1, triangle for trt 2, and diamone for trt 3, in the following sgplot program (SAS 9.2) or attachment.   Thanks!!


data test;
input trt temp value sd sdlo sdhi;
cards;

1 0     0      0     0      0
1 0.25 299    61.4  237.6  360.4
1 0.5   428    66.5  361.5  494.5
1 1     581    64.4  516.6  645.4
1 2     776    142   634    918
1 2.5   475    154   321    629
1 3     355    105   250    460
2 0     0      0     0      0
2 0.25  765    167   598    932
2 0.5   1020   180   840    1200
2 1     1400   322   1078   1722
2 2     1880   375   1505   2255
2 2.5   1060   404   656    1464
2 3     775    338   437    1113
3 0     0      0     0      0
3 0.25  2180  322   1858    2502
3 0.5   3240  634   2606    3874
3 1     4920  722   4198    5642
3 2     6860  1610  5250    8470
3 2.5   4400  1240  3160    5640
3 3     3600  1200  2400    4800
;
run;

proc sgplot data=test;

xaxis  label='Temperature' ;
yaxis  label="solicity" ;
title "";

series x = temp y = value / group=trt markerattrs=(size=9  color=black) ;
scatter x = temp y = value / group=trt markerattrs=(size=9 color=black) ;

run;

1 ACCEPTED SOLUTION

Accepted Solutions
Jay54
Meteorite | Level 14

If you have multiple columns instead of groups, you add a scatter plot for each treaatment and just set the mMARKERATTRS for each plot statement.

View solution in original post

19 REPLIES 19
DanH_sas
SAS Super FREQ

What version of SAS are you running?

John70
Calcite | Level 5

I use SAS 9.2

Jay54
Meteorite | Level 14

With SAS 9.2, you will have to build a custom style to get the marker shapes you want.  To ensure you will get the correct marker regardless of their position in the data, I normally just add dummy values in the data with group values I want at the top..  The X or Y values can be made missing to prevent plotting of these dummy values.  but these values ensure the assignment of all the group (or treatment) values and their order.

With SAS 9.2 GTL, you can use the INDEX option, and place the index values of the style element 1-12 in the data.

With SAS 9.3, you can use DiscreteAttrMap to deterministically tie specific marker shapes to specific treatment values.

Jay54
Meteorite | Level 14

If you have multiple columns instead of groups, you add a scatter plot for each treaatment and just set the mMARKERATTRS for each plot statement.

John70
Calcite | Level 5

Hi Sanjay,

thanks!  it works.

Jay54
Meteorite | Level 14

Which method did you go with?

John70
Calcite | Level 5

make  multiple columns instead of groups, plot for each treaatment and just set the mMARKERATTRS for each plot statement.   Thanks!

PGStats
Opal | Level 21

You should also look at the MODSTYLE style modification macro. It might provide you with enough flexibility for your purpose.. It is documented here : http://support.sas.com/documentation/cdl/en/statug/63347/HTML/default/viewer.htm#statug_odsgraph_sec...

PG

PG
John70
Calcite | Level 5

Hi PG,

Sounds it is a great way to work on this but I am new in SAS program. it will take me sometime to understand this.

Thanks!

John

John70
Calcite | Level 5

Hi PG,

Your suggestion works!  but how can I let legend show the corresponding symbols, not the line since the line is the same?  see attachment.

Thanks!

John

Jay54
Meteorite | Level 14

Note NAME option on scatter plot addition of KEYLEGEND stmt.

proc sgplot data=test;

xaxis  label='Temperature' ;
yaxis  label="solicity" ;
title "";

series x = temp y = value / group=trt markerattrs=(size=9  color=black) ;
scatter x = temp y = value / group=trt markerattrs=(size=9 color=black) name='s';
keylegend 's';

run;

John70
Calcite | Level 5


Thanks Sanjay!!!

one more question, why when output the figure as rtf,  the lines and marks in the figure are not right (see attachment) again?

John

Jay54
Meteorite | Level 14

On RTF, the default style has colored lines and markers.  You already set all markers to black.   If you want the lines to be black too, set the lineattrs on the series plot statement.  For thicker lines use - lineattrs=(color=black thickness=2).

Alternatively, you can just use STYEL=JOURNAL on the ODS RTF statement to get a fully black and white graph.  Then you don't need to set the line and marker attrs to black.

proc sgplot data=test;

xaxis  label='Temperature' ;
yaxis  label="solicity" ;
title "";

series x = temp y = value / group=trt lineattrs=(color=black) ;
scatter x = temp y = value / group=trt markerattrs=(size=9 color=black) name='s';
keylegend 's';

run;

John70
Calcite | Level 5

Hi Sanjay,

Many thanks!!  I tried per your suggestion, however the symbols in the RTF output were not what I wanted.  Instead of circle, triangle, and square specified by the program, the RTF output gave circle, +, and x.  When the plot was made without ODS rtf output, the SGPLOT gave a right symbols.  It seems that somehow %modstyle was affect by ODS. Could you please help on this?   Thanks!  John

(also refer the attached program)

The following program provides correct symbols.

%modstyle(name=markstyle, parent=statistical, type=CbyLbyM,
          markers=circle triangle square)
ods listing style=markstyle;

proc sgplot data=test;

xaxis  label='Temperature' ;
yaxis  label="Solicity" ;
title "";

series x = temp y = value / group=trt lineattrs=(pattern=solid color=black thickness=1) ;
scatter x = temp y = value / group=trt yerrorlower=sdlo yerrorupper=sdhi markerattrs=(size=9 color=black) name='Toto';
keylegend 'Toto'/position=topright location=inside across=1;

run;

The following program, when add rtf output, fail to provide correct symbols.

ods graphics on/noborder ; 
ods rtf file='C:\SAS\test1.rtf';

%modstyle(name=markstyle, parent=statistical, type=CbyLbyM,
          markers=circle triangle square)
ods listing style=markstyle;

proc sgplot data=test;

xaxis  label='Temperature' ;
yaxis  label="Solicity" ;
title "";

series x = temp y = value / group=trt lineattrs=(pattern=solid color=black thickness=1) ;
scatter x = temp y = value / group=trt yerrorlower=sdlo yerrorupper=sdhi markerattrs=(size=9 color=black) name='Toto';
keylegend 'Toto'/position=topright location=inside across=1;

run;

ods rtf close;

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 19 replies
  • 2110 views
  • 3 likes
  • 5 in conversation