Data visualization with SAS programming

SGploy symbol

Accepted Solution Solved
Reply
Contributor
Posts: 28
Accepted Solution

SGploy symbol

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;

Attachment

Accepted Solutions
Solution
‎06-12-2012 01:07 PM
SAS Super FREQ
Posts: 1,136

Re: SGploy symbol

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


All Replies
SAS Super FREQ
Posts: 925

Re: SGploy symbol

What version of SAS are you running?

Contributor
Posts: 28

Re: SGploy symbol

I use SAS 9.2

SAS Super FREQ
Posts: 1,136

Re: SGploy symbol

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.

Solution
‎06-12-2012 01:07 PM
SAS Super FREQ
Posts: 1,136

Re: SGploy symbol

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.

Contributor
Posts: 28

Re: SGploy symbol

Hi Sanjay,

thanks!  it works.

SAS Super FREQ
Posts: 1,136

Re: SGploy symbol

Which method did you go with?

Contributor
Posts: 28

Re: SGploy symbol

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

Respected Advisor
Posts: 4,804

Re: SGploy symbol

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
Contributor
Posts: 28

Re: SGploy symbol

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

Contributor
Posts: 28

Re: SGploy symbol

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

Attachment
SAS Super FREQ
Posts: 1,136

Re: SGploy symbol

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;

Contributor
Posts: 28

Re: SGploy symbol


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

Attachment
SAS Super FREQ
Posts: 1,136

Re: SGploy symbol

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;

Contributor
Posts: 28

Re: SGploy symbol

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;

Attachment
🔒 This topic is solved and locked.

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

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