Dear Community,
I created an input data set to produce a forrest plot (input data set attached as forrest.xlsx). The input dataset is in the exact format that I want my forrest plot to be. My code works as expected except that row number #22 (subgrp='Therapy*,' value '>=2') doesnt show up in the rtf output. The output is attached (forrest1.docx) and as you can see subgrp= ">=2"' doesnt show up in the rtf. When I dug further it seems like there is a tons of space between the row values. For example, when I run my code by restricting the input data for subgrp='Therapy*' only, my output looks like attached forrest2.docx.
Please advise
Below is my code:
(please note data final in proc sgrender is the forrest.xlsx dataset attached)
%let v21=20;
%let v22=70;
proc template;
define statgraph Forest_Plot2_with_Subgroups;
dynamic _color;
begingraph / axislineextent=data;
entryfootnote halign=center textattrs=(size=8 ) "Cohort 2 Subjects (N=50)";
entryfootnote halign=left textattrs=(size=8 ) " ";
entryfootnote halign=left textattrs=(size=8 )
"Note: Subgroup analysis by baseline weight (<=100 vs. >100 kg) is not performed because number of subjects in the >100 kg subgroup is less than 5.";
discreteAttrmap name='text';
value 'G' / textattrs=(weight=bold);
value other;
endDiscreteAttrmap;
discreteAttrvar attrvar=type var=type attrmap='text';
layout lattice / columns=1;
/*--Column headers--*/
sidebar / align=top;
layout lattice / columns=4 columnweights=(0.25 0.07 0.15 0.53);
entry textattrs=(size=8 /*weight=bold*/ color=darkblue) halign=left "Subgroup";
entry textattrs=(size=8 /*weight=bold*/ color=darkblue) halign=center "n/N" ;
entry textattrs=(size=8 /*weight=bold*/ color=darkblue) halign=left "% (95% CI)";
entry textattrs=(size=8 /*weight=bold*/ color=darkblue) halign=center "ORR, % (95% CI)";
endlayout;
endsidebar;
/*--Fourth column showing ORR graph--*/
layout overlay / xaxisopts=(display=(ticks tickvalues line)
tickvalueattrs=(size=7) linearopts=(tickvaluepriority=true
tickvaluelist=(0 10 20 30 40 50 60 70 80)))
yaxisopts=(reverse=true display=none offsetmax=0.02) walldisplay=none;
/*--Draw color Bands--*/
referenceline y=ref / lineattrs=(thickness=14 color=_color);
referenceline x=eval(coln(&v21, &v22))/ lineattrs=(pattern=shortdash) datatransparency=0.5;
/*--Draw ORR --*/
scatterplot y=subgrp x=pcnt / xerrorlower=low xerrorupper=high
markerattrs=(symbol=squarefilled color=darkblue) errorbarattrs=(color=black) /*errorbarcapshape=none*/;
/*--Draw axis labels--*/
/*--Draw subgrp, Patient Count, CI columns--*/
innermargin / align=left;
axistable y=subgrp value=subgrp / indentweight=indent textgroup=type display=(values) valueattrs=(size=7);
axistable y=subgrp value=ORR / display=(values) valueattrs=(size=7);
axistable y=subgrp value=CI / display=(values) valueattrs=(size=7);
endinnermargin;
endlayout;
endlayout;
endgraph;
end;
run;
options nodate nonumber orientation=landscape;
ods listing close;
ods rtf style=foreststyle file="&outdir\check.rtf" nogfootnote nogtitle bodytitle toc_data headery=720 footery=720;
ods graphics / reset imagename="fplot" attrpriority=none
height=7.8in width=7in
imagefmt=png
border=on;
ods proclabel=' ';
proc sgrender data=final template=Forest_Plot2_with_Subgroups;
dynamic _color='cxf0f0f0';
run;
Is it possible that the data values contain extra space characters? Sanjay discusses space characters in the context of Forest plots in this article.
Did you get the template from somewhere else? If so, please provide a link to the original source.
Hi Rick,
Thanks for the feed back. I have been using this program/template for a while w/o any issues until now. So I dont remember the source of it.
Anyways, I spent quite a few time with trial and error and found a solution in the format, which to me is really weird - something I am not understanding. Please let me know if you can help me understand it.
So , for the subgroup that I was having issue with, I had created a user defined formats. (I had done this for every subgroup in the table). Below is the format for the subgroup I am having issue with.
proc format;
value LINEPTXN 1= "1" 2= ">=2";
run;
With this format, I having the issue of category ">=2" not displaying in the rtf (attached as forrest1.docx in the original comment).
However, when I change the format to add a space before >=2, it works!
proc format;
value LINEPTXN 1= "1" 2= " >=2"; /*Please note a space before >= here vs the the first format w/o the space */
run;
Thanks,
Kuldeep
Be advised that the message windows on this forum strip out white space characters in many instances.
You need to post code containg spaces in a code box opened with the {i} other wise both of your example lines look like
value LINEPTXN 1= "1" 2= ">=2";
Example: In code box:
value LINEPTXN 1= "1" 2= ">=2"; value LINEPTXN 1= "1" 2= ">=2";
without
value LINEPTXN 1= "1" 2= ">=2";
value LINEPTXN 1= "1" 2= ">=2";
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9.
Early bird rate extended! Save $200 when you sign up by March 31.
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.