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

The Expected plot is below:

Manj_0-1618426165466.png

I have the following code 


ods path show;
ods path(prepend) work.templat(update);

ods pdf file="&g_outfile..PDF" nogtitle /*nogfootnote*/ bookmarkgen=no;
ods graphics on / reset=all width=1000px height=500px border=off ;

 

proc template;
define statgraph AEbyRelativeRisk;
dynamic _thk _grid;
begingraph;
layout lattice / columns=2 rowdatarange=union columngutter=1;

/*--Row block to get common external row axes--*/
rowaxes;
rowaxis / griddisplay=_grid display=(tickvalues) tickvalueattrs=(size=5);
endrowaxes;

/*--Column headers with filled background--*/
column2headers;
layout overlay;
entry " ";
endlayout;
layout overlay ;
entry "<--- Tmt1 Better Tmt2 Better --->";
endlayout;
endcolumn2headers;

/*--Left side cell with proportional values--*/
layout overlay / xaxisopts=(label="Percent" display=(ticks tickvalues label) labelattrs=(size=8) tickvalueattrs=(size=7));
referenceline y=teaex / lineattrs=(thickness=_thk) datatransparency=0.9;
scatterplot y=ae x=tmt1Pct / markerattrs=graphdata2(symbol=circlefilled size=10)
name='a' legendlabel="tmt1 (N=&NA)";
scatterplot y=ae x=tmt2Pct / markerattrs=graphdata1(symbol=trianglefilled size=10)
name='b' legendlabel="Tmt2 (N=&NB) ";
discretelegend 'a' 'b' / border=true halign=left valign=bottom valueattrs=(size=8) displayclipped=true;
endlayout;

/*--Right side cell with Relative Risk values--*/
layout overlay / xaxisopts=(label="Relative Risk with 0.95 CI (*ESC*){unicode '000a'x} tmt1 vs tmt2"
labelattrs=(size=8) tickvalueattrs=(size=7));
referenceline y=teaex / lineattrs=(thickness=_thk) datatransparency=0.9;
scatterplot y=ae x=RelRisk / xerrorlower=LowerCL xerrorupper=UpperCL
markerattrs=(symbol=circlefilled size=10);
referenceline x=1 / lineattrs=graphdatadefault (pattern=solid color=grey);
endlayout;

endlayout;
endgraph;
end;
run;

ods graphics / reset width=6in height=4in imagename='AEbyRelativeRisk';

proc sgrender data=ip template=AEbyRelativeRisk;
dynamic _thk='0' _grid='on';
run;


ods pdf close;

 

 

The figure I get is as below:

Manj_1-1618426528335.png

 

The issues are:

 

1) how to split each of the y axis tick values into two or more lines.

2) the figure looks very pale ,how to improve the texts and lines to be a bit more bold or darker so that it will be readable.

 

1 ACCEPTED SOLUTION

Accepted Solutions
Jay54
Meteorite | Level 14

On the ROWAXIS statement, use DISCRETEOPTS=(TICKVALUEFITPOLICY=SPLIT).  The tick value will be split if it does not fit.  You can reduce the width of the cell.

 

Else, use DISCRETEOPTS=(TICKVALUEFITPOLICY=SPLITALWAYS) and specify the Split character.

 

Overall, you can reduce the graph size and increase the DPI=200 or higher.  This will scale up the fonts.  You can also set bigger fonts for the tick values and other texts in the graph.

 

ods graphics on / reset=all width=6in height=3in border=off ;

ods pdf dpi=300;

 

See examples:

https://blogs.sas.com/content/graphicallyspeaking/2015/10/31/adverse-events-graph-with-nnt/

https://blogs.sas.com/content/graphicallyspeaking/2017/11/08/long-category-values/

 

View solution in original post

10 REPLIES 10
Manj
Fluorite | Level 6
 
Jay54
Meteorite | Level 14

On the ROWAXIS statement, use DISCRETEOPTS=(TICKVALUEFITPOLICY=SPLIT).  The tick value will be split if it does not fit.  You can reduce the width of the cell.

 

Else, use DISCRETEOPTS=(TICKVALUEFITPOLICY=SPLITALWAYS) and specify the Split character.

 

Overall, you can reduce the graph size and increase the DPI=200 or higher.  This will scale up the fonts.  You can also set bigger fonts for the tick values and other texts in the graph.

 

ods graphics on / reset=all width=6in height=3in border=off ;

ods pdf dpi=300;

 

See examples:

https://blogs.sas.com/content/graphicallyspeaking/2015/10/31/adverse-events-graph-with-nnt/

https://blogs.sas.com/content/graphicallyspeaking/2017/11/08/long-category-values/

 

Manj
Fluorite | Level 6
Thanks for the suggestion. It worked!
I have used tickvalueattrs=(size=8 weight=bold) ) DISCRETEOPTS= (TICKVALUEFITPOLICY=SPLITALWAYS tickvaluesplitchar='~') which shows the y axis tick values readable.
Manj
Fluorite | Level 6

One more issue:
How to display the xaxis for the right panel as 0.25, 0.50 1 2 4 8 ? my code below. This gives 0.25 1 then 4 only

Manj_0-1618499415987.png

 

Jay54
Meteorite | Level 14

You can try using the TICKVALUEFITPOLICY=NONE for XAXISOPTS.  This will avoid thinning of values due to collision of tick values.  Not sure why you need TICKDISPLAYLIST.

 

https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/grstatgraph/n0fksz728ytyz2n1ws13vlnkudyn.htm#...

Manj
Fluorite | Level 6
Hi
I have tried Tickvaluepolicy=None as well , but that doesn’t give the values in display list .
Jay54
Meteorite | Level 14

Do you get all the values if you remove 0.25 and 0.5 from the list?  These values may be causing some values to be dropped.  You can also increase the relative width of the right cell.

Manj
Fluorite | Level 6

Hi 

the issue here is I need to present the x axis on a scale using powers of 2 (..., 1/4, 1/2, 1, 2, 4, ...) for the purpose of fitting a larger range of relative risk values, while also keeping the reference line of 1 closer to the center of the panel. This is the requirement and im unable to do this using tickvaluelist and policy.

Jay54
Meteorite | Level 14

Some such graphs have used a log scale on the x-axis to get the result you need.

 

Please see page 14 of this paper.  The xaxisopts for the 2nd cell uses a TYPE of log .

https://www.mwsug.org/proceedings/2014/SS/MWSUG-2014-SS07.pdf

 

Manj
Fluorite | Level 6
Thank a lot. It worked and got what I wanted.

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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