Hi all, I have an issue using SymbolChar statement to define MARKERATTRS symbol value for a scatterplot.
When I increase the size of the symbol in MARKERATTRS, then the symbol is moving on the Y-Axis. it looks like the symbol has something like POSITION=BOTTOM whereas I'm expecting MIDDLE or CENTER value. I can try to decrease the impact by adding vertical offset to my symbol. But if anybody has an idea of what is happening and how to avoid this it would be great for me (I'm using SAS 9.4 9.4 (TS1M5)).
Thank you for reading.
Mickael
data WORK.PLOT ;
infile datalines4 dsd missover dlm=',' ;
length DAY GEOMEAN LCLM UCLM 8. ;
input DAY GEOMEAN LCLM UCLM ;
datalines4 ;
1,5.851,5.721,5.983
15,10.103,8.531,11.965
29,17.723,14.523,21.628
57,25.449,20.171,32.108
71,76.898,62.926,93.972
85,119.914,101.658,141.447
;;;;
run ;
** Style to be used for the plot ** ;
/*this SAS style can be used: STYLES.Journal;*/
ods path (PREPEND) WORK.GRAPH ;
proc template ;
define statgraph TestSymbolChar / store=WORK.GRAPH ;
mvar GraphTitle EmDashSize ;
dynamic XVar YMean YLowBound YUpBound ;
begingraph ;
symbolchar name=EmDash char='2014'x / /*textattrs=(size=20pt)*/ hoffset=0 voffset=0 /*+0.1*/ ;
entrytitle textattrs=(size=10pt weight=bold) GraphTitle ;
layout overlay / xaxisopts=(label='Day')
yaxisopts=(griddisplay=on type=log logopts=(base=10 Thresholdmax=1 Thresholdmin=1 minorticks=true minortickcount=8 minorgrid=true)
label='Geometric Mean (95%CI)' griddisplay=on) ;
scatterplot x=XVar y=YMean / markerattrs=(symbol=EmDash size=EmDashSize weight=bold color=black) errorbarcapshape=serif
errorbarattrs=(thickness=1pt color=black) yerrorlower=YLowBound yerrorupper=YUpBound name="GeoMean" ;
endlayout ;
endgraph ;
end ;
quit ;
*** Path of the template catalogs *** ;
ods path SASUSER.TEMPLAT(UPDATE) SASHELP.TMPLMST(READ) WORK.MYTEMP(READ) WORK.GRAPH(READ) ;
** SAS SGRender ** ;
%let EmDashSize= ;
%let GraphTitle=Using &EmDashSize. as a size for Symbol Char ;
%let FigureRoot=C:\Temp ;
option center ;
ods listing close ;
ods graphics on / reset=index imagename="TestSymbolCharEmpty" height=10cm width=16cm noborder ;
ods html style=styles.journal2 image_dpi=150 gpath="&FigureRoot." path="&FigureRoot." (url=none) file="output.html" ;
*goptions reset=all ;
ods graphics / outputfmt=png ;
proc sgrender data=WORK.PLOT template=TestSymbolChar description='' ;
dynamic XVar='DAY' YMean='GEOMEAN' YLowBound='LCLM' YUpBound='UCLM' ;
run ;
ods html close ;
ods graphics off ;
ods listing ;
** SAS SGRender ** ;
%let EmDashSize=12pt ;
%let GraphTitle=Using &EmDashSize. as a size for Symbol Char ;
%let FigureRoot=C:\Temp ;
option center ;
ods listing close ;
ods graphics on / reset=index imagename="TestSymbolChar12pt" height=10cm width=16cm noborder ;
ods html style=styles.journal2 image_dpi=150 gpath="&FigureRoot." path="&FigureRoot." (url=none) file="output.html" ;
*goptions reset=all ;
ods graphics / outputfmt=png ;
proc sgrender data=WORK.PLOT template=TestSymbolChar description='' ;
dynamic XVar='DAY' YMean='GEOMEAN' YLowBound='LCLM' YUpBound='UCLM' ;
run ;
ods html close ;
ods graphics off ;
ods listing ;
%let EmDashSize=18pt ;
%let GraphTitle=Using &EmDashSize. as a size for Symbol Char ;
%let FigureRoot=C:\Temp ;
option center ;
ods listing close ;
ods graphics on / reset=index imagename="TestSymbolChar18pt" height=10cm width=16cm noborder ;
ods html style=styles.journal2 image_dpi=150 gpath="&FigureRoot." path="&FigureRoot." (url=none) file="output.html" ;
*goptions reset=all ;
ods graphics / outputfmt=png ;
proc sgrender data=WORK.PLOT template=TestSymbolChar description='' ;
dynamic XVar='DAY' YMean='GEOMEAN' YLowBound='LCLM' YUpBound='UCLM' ;
run ;
ods html close ;
ods graphics off ;
ods listing ;
%let EmDashSize=40 ;
%let GraphTitle=Using &EmDashSize. as a size for Symbol Char ;
%let FigureRoot=C:\Temp ;
option center ;
ods listing close ;
ods graphics on / reset=index imagename="TestSymbolChar4P0" height=10cm width=16cm noborder ;
ods html style=styles.journal2 image_dpi=150 gpath="&FigureRoot." path="&FigureRoot." (url=none) file="output.html" ;
*goptions reset=all ;
ods graphics / outputfmt=png ;
proc sgrender data=WORK.PLOT template=TestSymbolChar description='' ;
dynamic XVar='DAY' YMean='GEOMEAN' YLowBound='LCLM' YUpBound='UCLM' ;
run ;
ods html close ;
ods graphics off ;
ods listing ;
Please post your code formatted, using the appropriate icon.
data WORK.PLOT ;
infile datalines4 dsd missover dlm=',' ;
length DAY GEOMEAN LCLM UCLM 8. ;
input DAY GEOMEAN LCLM UCLM ;
datalines4 ;
1,5.851,5.721,5.983
15,10.103,8.531,11.965
29,17.723,14.523,21.628
57,25.449,20.171,32.108
71,76.898,62.926,93.972
85,119.914,101.658,141.447
;;;;
run ;
proc sql noprint ;
select distinct DAY into :XAxisValues separated by ' ' from WORK.PLOT order by DAY ;
quit ;
%put XAxisValues: &XAxisValues. Days ;
** Style to be used for the plot ** ;
/*this SAS style can be used: STYLES.Journal;*/
ods path (PREPEND) WORK.GRAPH ;
proc template ;
define statgraph TestSymbolChar / store=WORK.GRAPH ;
mvar GraphTitle EmDashHexa EmDashSize XAxisValues ;
nmvar SymVOffset ;
dynamic XVar YMean YLowBound YUpBound ;
begingraph ;
symbolchar name=EmDash char=EmDashHexa / /*textattrs=(size=20pt)*/ hoffset=0 voffset=SymVOffset /*+0.1*/ ;
entrytitle textattrs=(size=10pt weight=bold) GraphTitle ;
layout overlay / xaxisopts=(label='Day' linearopts=(tickvaluelist=XAxisValues))
yaxisopts=(griddisplay=on type=log logopts=(base=10 Thresholdmax=1 Thresholdmin=1 minorticks=true minortickcount=8 minorgrid=true)
label='Geometric Mean (95%CI)' griddisplay=on) ;
scatterplot x=XVar y=YMean / markerattrs=(symbol=EmDash size=EmDashSize weight=bold color=black) errorbarcapshape=serif
errorbarattrs=(thickness=1pt color=black) yerrorlower=YLowBound yerrorupper=YUpBound name="GeoMean" ;
referenceline y=77 / lineattrs=(color=red pattern=2) curvelabel='77' curvelabelattrs=(color=black size=6) ;
referenceline y=120 / lineattrs=(color=red pattern=2) curvelabel='120' curvelabelattrs=(color=black size=6) ;
endlayout ;
endgraph ;
end ;
quit ;
*** Path of the template catalogs *** ;
ods path SASUSER.TEMPLAT(UPDATE) SASHELP.TMPLMST(READ) WORK.MYTEMP(READ) WORK.GRAPH(READ) ;
%MACRO testSymbolChar( /* Test different Symbol to show geometric mean as a straight line */
EmDashHexa=, /* Hexadecimal code for symbol character */
EmDashSize=, /* Size of the symbol character */
SymVOffset=0, /* Vertical Offset of the symbol character */
imagename=, /* Name of the PNG file */
GraphTemplate=TestSymbolChar /* Template to use for SGRENDER */
) ;
%** SAS SGRender ** ;
%let GraphTitle=Using &EmDashHexa. with &EmDashSize. as a size for Symbol Char ;
%let FigureRoot=C:\Temp ;
option center ;
ods listing close ;
ods graphics on / reset=index imagename="&imagename." height=10cm width=16cm noborder ;
ods html style=styles.journal2 image_dpi=150 gpath="&FigureRoot." path="&FigureRoot." (url=none) file="output.html" ;
%*goptions reset=all ;
ods graphics / outputfmt=png ;
proc sgrender data=WORK.PLOT template=&GraphTemplate. description='' ;
dynamic XVar='DAY' YMean='GEOMEAN' YLowBound='LCLM' YUpBound='UCLM' ;
run ;
ods html close ;
ods graphics off ;
ods listing ;
%MEND testSymbolChar ;
/*
%let EmDashHexa='2012'x ;* Figure Dash * ;
%let EmDashHexa='2013'x ;* En Dash * ;
%let EmDashHexa='2014'x ;* Em Dash * ;
%let EmDashHexa='2015'x ;* Horizontal Bar * ;
%let EmDashHexa='002D'x ;* Hyphen-Minus * ;
%let EmDashHexa='0336'x ;* Combining Long Stroke Overlay * ;
%let EmDashHexa='2500'x ;* Box Drawings Light Horizontal * ;
%let EmDashHexa='25AC'x ;* Black Rectangle * ;
%let EmDashHexa='A7F7'x ;* Undefined * ;
*/
%testSymbolChar(EmDashHexa=%bquote('2014'x),EmDashSize=%bquote(),imagename=TestEmDashSizeEmpty) ;
%testSymbolChar(EmDashHexa=%bquote('2014'x),EmDashSize=%bquote(12pt),imagename=TestEmDashSize12pt) ;
%testSymbolChar(EmDashHexa=%bquote('2014'x),EmDashSize=%bquote(40),imagename=TestEmDashSize40) ;
%testSymbolChar(EmDashHexa=%bquote('2015'x),EmDashSize=%bquote(),imagename=TestHBarSizeEmpty) ;
%testSymbolChar(EmDashHexa=%bquote('2015'x),EmDashSize=%bquote(12pt),imagename=TestHBarSize12pt) ;
%testSymbolChar(EmDashHexa=%bquote('2015'x),EmDashSize=%bquote(40),imagename=TestHBarSize40) ;
%testSymbolChar(EmDashHexa=%bquote('002D'x),EmDashSize=%bquote(),imagename=TestHyphenSizeEmpty) ;
%testSymbolChar(EmDashHexa=%bquote('002D'x),EmDashSize=%bquote(12pt),imagename=TestHyphenSize12pt) ;
%testSymbolChar(EmDashHexa=%bquote('002D'x),EmDashSize=%bquote(40),imagename=TestHyphenSize40) ;
%testSymbolChar(EmDashHexa=%bquote('0336'x),EmDashSize=%bquote(),imagename=TestCLSOSizeEmpty) ;
%testSymbolChar(EmDashHexa=%bquote('0336'x),EmDashSize=%bquote(12pt),imagename=TestCLSOSize12pt) ;
%testSymbolChar(EmDashHexa=%bquote('0336'x),EmDashSize=%bquote(40),imagename=TestCLSOSize40) ;
%testSymbolChar(EmDashHexa=%bquote('2012'x),EmDashSize=%bquote(),imagename=TestFigDashSizeEmpty) ;
%testSymbolChar(EmDashHexa=%bquote('2012'x),EmDashSize=%bquote(12pt),imagename=TestFigDashSize12pt) ;
%testSymbolChar(EmDashHexa=%bquote('2012'x),EmDashSize=%bquote(40),imagename=TestFigDashSize40) ;
%testSymbolChar(EmDashHexa=%bquote('2013'x),EmDashSize=%bquote(),imagename=TestEnDashSizeEmpty) ;
%testSymbolChar(EmDashHexa=%bquote('2013'x),EmDashSize=%bquote(12pt),imagename=TestEnDashSize12pt) ;
%testSymbolChar(EmDashHexa=%bquote('2013'x),EmDashSize=%bquote(40),imagename=TestEnDashSize40) ;
%testSymbolChar(EmDashHexa=%bquote('2500'x),EmDashSize=%bquote(),imagename=TestBDLHSizeEmpty) ;
%testSymbolChar(EmDashHexa=%bquote('2500'x),EmDashSize=%bquote(12pt),imagename=TestBDLHSize12pt) ;
%testSymbolChar(EmDashHexa=%bquote('2500'x),EmDashSize=%bquote(40),imagename=TestBDLHSize40) ;
%testSymbolChar(EmDashHexa=%bquote('25AC'x),EmDashSize=%bquote(),imagename=TestBlackRectizeEmpty) ;
%testSymbolChar(EmDashHexa=%bquote('25AC'x),EmDashSize=%bquote(12pt),imagename=TestBlackRectSize12pt) ;
%testSymbolChar(EmDashHexa=%bquote('25AC'x),EmDashSize=%bquote(40),imagename=TestBlackRectSize40) ;
%testSymbolChar(EmDashHexa=%bquote('A7F7'x),EmDashSize=%bquote(),imagename=TestUndefSizeEmpty) ;
%testSymbolChar(EmDashHexa=%bquote('A7F7'x),EmDashSize=%bquote(12pt),imagename=TestUndefSize12pt) ;
%testSymbolChar(EmDashHexa=%bquote('A7F7'x),EmDashSize=%bquote(40),imagename=TestUndefSize40) ;
/* Not so bad solution */
%testSymbolChar(EmDashHexa=%bquote('2500'x),EmDashSize=%bquote(20),imagename=TestBDLHSize20) ;
%testSymbolChar(EmDashHexa=%bquote('2014'x),EmDashSize=%bquote(20),SymVOffset=0.08,imagename=TestEmDashSize20Offset) ;
HOFFSET, VOFFSET, SIZE, SCALE and other options can be used to control the positioning of the symbol within the bounding box. See doc at:
https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/grstatgraph/p0cf4zbevcqzxjn19w5berzi6ocd.htm
Save $250 on SAS Innovate and get a free advance copy of the new SAS For Dummies book! Use the code "SASforDummies" to register. Don't miss out, May 6-9, in Orlando, Florida.
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.
Ready to level-up your skills? Choose your own adventure.