- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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;
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
What version of SAS are you running?
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
I use SAS 9.2
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Hi Sanjay,
thanks! it works.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Which method did you go with?
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
make multiple columns instead of groups, plot for each treaatment and just set the mMARKERATTRS for each plot statement. Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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;