<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic A problem of row space in the forest plot in Graphics Programming</title>
    <link>https://communities.sas.com/t5/Graphics-Programming/A-problem-of-row-space-in-the-forest-plot/m-p/268448#M9611</link>
    <description>&lt;P&gt;Dear all,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I followed the example from SAS to create a forest plot.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But there seems a "double-space" condition in my graphic.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Would you please help me find out the problem is?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you very much!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please find the attachment for my graphic, and&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is my program:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/*--Add "Id" to identify methods headings from values                      --*/
data forest;
  input Id methods $3-20 Countpct $22-40 HR  lci  hci;
  indentWt=1;
  ObsId=_n_;
datalines;
1	Primary analysis	0.64 (0.43-0.95)	0.64	0.43	0.95
1	Grace period		.	                .	.       .
2	60 days	                0.70 (0.49-1.01)	0.7	0.49	1.01
2	90 days	                1.06 (0.86-1.32)	1.06	0.86	1.32
1	Age groups		    .	                .	.       .
2	&amp;lt;=65 years	        0.43 (0.19-0.93)	0.43	0.19	0.93
2	&amp;gt;65 years	        0.69 (0.44-1.08)	0.69	0.44	1.08
1	Gender		        .	                .	.       .
2	Female	                0.69 (0.43-1.10)	0.69	0.43	1.1
2	Male	                0.57 (0.28-1.15)	0.57	0.28	1.15
1	CVD history		.	                .	.       .
2	Without	                0.69 (0.43-1.08)	0.69	0.43	1.08
2	With	                0.50 (0.24-1.06)	0.5	0.24	1.06
;
run;

data forest2;
  set forest;
  /*if count ne . then CountPct=put(count, 4.0) || "(" || put(percent, 3.0) || ")";*/
  if mod(obsId-1, 6) in (1, 2, 3) then ref=obsId;
    /* Reduce indent for methods heading */
  if id=1 then indentWt=0;
run;

/**
 * Forest plot template using a one-column outermost lattice layout.
 * The header uses a nested lattice layout in the top side bar. 
 * An overlay layout makes up the main area belci it.
 * The left side table of values are axis tables placed inside
 * inner margin of the overlay layout.
 */
proc template;
  define statgraph forestAxisTable;
    dynamic  _bandColor _headerColor;
    begingraph;

      discreteattrmap name='text' / trimleading=true;
        value '1' / textAttrs=(size=7 weight=bold); 
        value '2' / textAttrs=(color=gray size=6 weight=normal); 
      enddiscreteattrmap;

      discreteattrvar attrvar=txtDAV var=id attrmap='text';

      layout lattice / columns=1;

         /*--Column headers--*/
        sidebar / align=top;
          layout lattice / columns=2 rowweights=uniform columnweights=(0.35 0.65)
                            backgroundcolor=_headerColor opaque=true;
              entry textAttrs=(size=8 weight=bold) hAlign=left "Methods"
                                          hAlign=right " HR (95% CI)";
              entry textAttrs=(size=8 weight=bold) "Hazard Ratio";
          endLayout;
        endsidebar;

        /* Single cell with inner margins for left and right tables */
        layout overlay / xAxisOpts=(display=(line ticks tickvalues) 
                            tickValueAttrs=(size=6 weight=bold)
                            labelAttrs=(size=6 weight=bold)
                            linearOpts=(tickValuePriority=true 
                                        tickValueList=(0.0 0.5 1.0 1.5 2.0))
                              offsetMin=0.1
                            )
                      yAxisOpts=(reverse=true display=none offsetMin=0) wallDisplay=none;

          /* Left-side table */
          innerMargin / align=left gutter=0.1in;
            axisTable y=obsId value=Methods / textGroup=txtDAV
                          indentWeight=indentwt display=(values);
            axisTable y=obsId value=CountPct /  display=(values);
          endInnerMargin;

          /* Odds Ratio plot */
          referenceLine y=ref / lineAttrs=(thickness=15 color=_bandColor);
          scatterPlot y=obsId x=HR / markerAttrs=(symbol=squareFilled)
                          xErrorLower=LCI xErrorUpper=HCI errorBarCapShape=none;
          referenceLine x=1;

        endLayout; /* overlay */

      endLayout; /* lattice */
    endgraph;
  end;
run;

ods _all_ close;
ods listing image_dpi=300;
ods graphics / reset width=6in height=4.5in imagename='SAS94M2_ForestPlot_GTL';

proc sgrender data=forest2 template=forestAxisTable;
  dynamic _bandColor='cxf0f0f0' _headerColor='cxd0d0d0';
run;

ods _all_ close;&lt;/CODE&gt;&lt;/PRE&gt;&lt;BR /&gt;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/12512i8FA731F7552F268D/image-size/large?v=1.0&amp;amp;px=600" border="0" alt="forest plot.png" title="forest plot.png" /&gt;</description>
    <pubDate>Thu, 05 May 2016 04:39:35 GMT</pubDate>
    <dc:creator>JayL</dc:creator>
    <dc:date>2016-05-05T04:39:35Z</dc:date>
    <item>
      <title>A problem of row space in the forest plot</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/A-problem-of-row-space-in-the-forest-plot/m-p/268448#M9611</link>
      <description>&lt;P&gt;Dear all,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I followed the example from SAS to create a forest plot.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But there seems a "double-space" condition in my graphic.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Would you please help me find out the problem is?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you very much!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please find the attachment for my graphic, and&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is my program:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/*--Add "Id" to identify methods headings from values                      --*/
data forest;
  input Id methods $3-20 Countpct $22-40 HR  lci  hci;
  indentWt=1;
  ObsId=_n_;
datalines;
1	Primary analysis	0.64 (0.43-0.95)	0.64	0.43	0.95
1	Grace period		.	                .	.       .
2	60 days	                0.70 (0.49-1.01)	0.7	0.49	1.01
2	90 days	                1.06 (0.86-1.32)	1.06	0.86	1.32
1	Age groups		    .	                .	.       .
2	&amp;lt;=65 years	        0.43 (0.19-0.93)	0.43	0.19	0.93
2	&amp;gt;65 years	        0.69 (0.44-1.08)	0.69	0.44	1.08
1	Gender		        .	                .	.       .
2	Female	                0.69 (0.43-1.10)	0.69	0.43	1.1
2	Male	                0.57 (0.28-1.15)	0.57	0.28	1.15
1	CVD history		.	                .	.       .
2	Without	                0.69 (0.43-1.08)	0.69	0.43	1.08
2	With	                0.50 (0.24-1.06)	0.5	0.24	1.06
;
run;

data forest2;
  set forest;
  /*if count ne . then CountPct=put(count, 4.0) || "(" || put(percent, 3.0) || ")";*/
  if mod(obsId-1, 6) in (1, 2, 3) then ref=obsId;
    /* Reduce indent for methods heading */
  if id=1 then indentWt=0;
run;

/**
 * Forest plot template using a one-column outermost lattice layout.
 * The header uses a nested lattice layout in the top side bar. 
 * An overlay layout makes up the main area belci it.
 * The left side table of values are axis tables placed inside
 * inner margin of the overlay layout.
 */
proc template;
  define statgraph forestAxisTable;
    dynamic  _bandColor _headerColor;
    begingraph;

      discreteattrmap name='text' / trimleading=true;
        value '1' / textAttrs=(size=7 weight=bold); 
        value '2' / textAttrs=(color=gray size=6 weight=normal); 
      enddiscreteattrmap;

      discreteattrvar attrvar=txtDAV var=id attrmap='text';

      layout lattice / columns=1;

         /*--Column headers--*/
        sidebar / align=top;
          layout lattice / columns=2 rowweights=uniform columnweights=(0.35 0.65)
                            backgroundcolor=_headerColor opaque=true;
              entry textAttrs=(size=8 weight=bold) hAlign=left "Methods"
                                          hAlign=right " HR (95% CI)";
              entry textAttrs=(size=8 weight=bold) "Hazard Ratio";
          endLayout;
        endsidebar;

        /* Single cell with inner margins for left and right tables */
        layout overlay / xAxisOpts=(display=(line ticks tickvalues) 
                            tickValueAttrs=(size=6 weight=bold)
                            labelAttrs=(size=6 weight=bold)
                            linearOpts=(tickValuePriority=true 
                                        tickValueList=(0.0 0.5 1.0 1.5 2.0))
                              offsetMin=0.1
                            )
                      yAxisOpts=(reverse=true display=none offsetMin=0) wallDisplay=none;

          /* Left-side table */
          innerMargin / align=left gutter=0.1in;
            axisTable y=obsId value=Methods / textGroup=txtDAV
                          indentWeight=indentwt display=(values);
            axisTable y=obsId value=CountPct /  display=(values);
          endInnerMargin;

          /* Odds Ratio plot */
          referenceLine y=ref / lineAttrs=(thickness=15 color=_bandColor);
          scatterPlot y=obsId x=HR / markerAttrs=(symbol=squareFilled)
                          xErrorLower=LCI xErrorUpper=HCI errorBarCapShape=none;
          referenceLine x=1;

        endLayout; /* overlay */

      endLayout; /* lattice */
    endgraph;
  end;
run;

ods _all_ close;
ods listing image_dpi=300;
ods graphics / reset width=6in height=4.5in imagename='SAS94M2_ForestPlot_GTL';

proc sgrender data=forest2 template=forestAxisTable;
  dynamic _bandColor='cxf0f0f0' _headerColor='cxd0d0d0';
run;

ods _all_ close;&lt;/CODE&gt;&lt;/PRE&gt;&lt;BR /&gt;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/12512i8FA731F7552F268D/image-size/large?v=1.0&amp;amp;px=600" border="0" alt="forest plot.png" title="forest plot.png" /&gt;</description>
      <pubDate>Thu, 05 May 2016 04:39:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/A-problem-of-row-space-in-the-forest-plot/m-p/268448#M9611</guid>
      <dc:creator>JayL</dc:creator>
      <dc:date>2016-05-05T04:39:35Z</dc:date>
    </item>
    <item>
      <title>Re: A problem of row space in the forest plot</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/A-problem-of-row-space-in-the-forest-plot/m-p/268467#M9613</link>
      <description>&lt;P&gt;Hi JayL&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Can you try adjusting the width and height in the following statement to see if it makes a difference?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="token statement"&gt;ods&lt;/SPAN&gt; &lt;SPAN class="token keyword"&gt;graphics&lt;/SPAN&gt; &lt;SPAN class="token operator"&gt;/&lt;/SPAN&gt; &lt;SPAN class="token keyword"&gt;reset&lt;/SPAN&gt; width&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;6&lt;/SPAN&gt;&lt;SPAN class="token operator"&gt;in&lt;/SPAN&gt; height&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;4.5&lt;/SPAN&gt;&lt;SPAN class="token operator"&gt;in&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 05 May 2016 08:57:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/A-problem-of-row-space-in-the-forest-plot/m-p/268467#M9613</guid>
      <dc:creator>Norman21</dc:creator>
      <dc:date>2016-05-05T08:57:45Z</dc:date>
    </item>
    <item>
      <title>Re: A problem of row space in the forest plot</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/A-problem-of-row-space-in-the-forest-plot/m-p/268495#M9614</link>
      <description>&lt;P&gt;Hi Norman,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks so much for your help.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've tried the method you recommend, however, it only changes the overall size of the graph proporionally, with no changes in&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;the space between rows.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to find an option that can change the line space under axistable, but has not figured it out yet.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Jay&lt;/P&gt;</description>
      <pubDate>Thu, 05 May 2016 12:55:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/A-problem-of-row-space-in-the-forest-plot/m-p/268495#M9614</guid>
      <dc:creator>JayL</dc:creator>
      <dc:date>2016-05-05T12:55:02Z</dc:date>
    </item>
    <item>
      <title>Re: A problem of row space in the forest plot</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/A-problem-of-row-space-in-the-forest-plot/m-p/268546#M9616</link>
      <description>&lt;P&gt;The height of your plot is too tall for the number of observations yoy have. &amp;nbsp;I suggest you reduce your height o 2.6" in the BEGINGRAPH statement. &amp;nbsp;Also, remove the OFFSETMIN=0 in the YAxisOpts. &amp;nbsp;Program attached.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/3059i4C7BEC1562280EAE/image-size/original?v=v2&amp;amp;px=-1" border="0" alt="SAS94M2_ForestPlot_GTL.png" title="SAS94M2_ForestPlot_GTL.png" /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data forest;&lt;BR /&gt; input Id methods $3-20 Countpct $22-40 HR lci hci;&lt;BR /&gt; indentWt=1;&lt;BR /&gt; ObsId=_n_;&lt;BR /&gt;datalines;&lt;BR /&gt;1 Primary analysis 0.64 (0.43-0.95) 0.64 0.43 0.95&lt;BR /&gt;1 Grace period . . . .&lt;BR /&gt;2 60 days 0.70 (0.49-1.01) 0.7 0.49 1.01&lt;BR /&gt;2 90 days 1.06 (0.86-1.32) 1.06 0.86 1.32&lt;BR /&gt;1 Age groups . . . .&lt;BR /&gt;2 &amp;lt;=65 years 0.43 (0.19-0.93) 0.43 0.19 0.93&lt;BR /&gt;2 &amp;gt;65 years 0.69 (0.44-1.08) 0.69 0.44 1.08&lt;BR /&gt;1 Gender . . . .&lt;BR /&gt;2 Female 0.69 (0.43-1.10) 0.69 0.43 1.1&lt;BR /&gt;2 Male 0.57 (0.28-1.15) 0.57 0.28 1.15&lt;BR /&gt;1 CVD history . . . .&lt;BR /&gt;2 Without 0.69 (0.43-1.08) 0.69 0.43 1.08&lt;BR /&gt;2 With 0.50 (0.24-1.06) 0.5 0.24 1.06&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;data forest2;&lt;BR /&gt; set forest;&lt;BR /&gt; /*if count ne . then CountPct=put(count, 4.0) || "(" || put(percent, 3.0) || ")";*/&lt;BR /&gt; if mod(obsId-1, 6) in (1, 2, 3) then ref=obsId;&lt;BR /&gt; /* Reduce indent for methods heading */&lt;BR /&gt; if id=1 then indentWt=0;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;/**&lt;BR /&gt; * Forest plot template using a one-column outermost lattice layout.&lt;BR /&gt; * The header uses a nested lattice layout in the top side bar. &lt;BR /&gt; * An overlay layout makes up the main area belci it.&lt;BR /&gt; * The left side table of values are axis tables placed inside&lt;BR /&gt; * inner margin of the overlay layout.&lt;BR /&gt; */&lt;BR /&gt;proc template;&lt;BR /&gt; define statgraph forestAxisTable;&lt;BR /&gt; dynamic _bandColor _headerColor;&lt;BR /&gt; begingraph / designheight=2.6in;&lt;/P&gt;
&lt;P&gt;discreteattrmap name='text' / trimleading=true;&lt;BR /&gt; value '1' / textAttrs=(size=7 weight=bold); &lt;BR /&gt; value '2' / textAttrs=(color=gray size=6 weight=normal); &lt;BR /&gt; enddiscreteattrmap;&lt;/P&gt;
&lt;P&gt;discreteattrvar attrvar=txtDAV var=id attrmap='text';&lt;/P&gt;
&lt;P&gt;layout lattice / columns=1;&lt;/P&gt;
&lt;P&gt;/*--Column headers--*/&lt;BR /&gt; sidebar / align=top;&lt;BR /&gt; layout lattice / columns=2 rowweights=uniform columnweights=(0.35 0.65)&lt;BR /&gt; backgroundcolor=_headerColor opaque=true;&lt;BR /&gt; entry textAttrs=(size=8 weight=bold) hAlign=left "Methods"&lt;BR /&gt; hAlign=right " HR (95% CI)";&lt;BR /&gt; entry textAttrs=(size=8 weight=bold) "Hazard Ratio";&lt;BR /&gt; endLayout;&lt;BR /&gt; endsidebar;&lt;/P&gt;
&lt;P&gt;/* Single cell with inner margins for left and right tables */&lt;BR /&gt; layout overlay / xAxisOpts=(display=(line ticks tickvalues) &lt;BR /&gt; tickValueAttrs=(size=6 weight=bold)&lt;BR /&gt; labelAttrs=(size=6 weight=bold)&lt;BR /&gt; linearOpts=(tickValuePriority=true &lt;BR /&gt; tickValueList=(0.0 0.5 1.0 1.5 2.0))&lt;BR /&gt; offsetMin=0.1&lt;BR /&gt; )&lt;BR /&gt; yAxisOpts=(reverse=true display=none) wallDisplay=none;&lt;/P&gt;
&lt;P&gt;/* Left-side table */&lt;BR /&gt; innerMargin / align=left gutter=0.1in;&lt;BR /&gt; axisTable y=obsId value=Methods / textGroup=txtDAV&lt;BR /&gt; indentWeight=indentwt display=(values);&lt;BR /&gt; axisTable y=obsId value=CountPct / display=(values);&lt;BR /&gt; endInnerMargin;&lt;/P&gt;
&lt;P&gt;/* Odds Ratio plot */&lt;BR /&gt; referenceLine y=ref / lineAttrs=(thickness=15 color=_bandColor);&lt;BR /&gt; scatterPlot y=obsId x=HR / markerAttrs=(symbol=squareFilled)&lt;BR /&gt; xErrorLower=LCI xErrorUpper=HCI errorBarCapShape=none;&lt;BR /&gt; referenceLine x=1;&lt;/P&gt;
&lt;P&gt;endLayout; /* overlay */&lt;/P&gt;
&lt;P&gt;endLayout; /* lattice */&lt;BR /&gt; endgraph;&lt;BR /&gt; end;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;ods _all_ close;&lt;BR /&gt;ods listing image_dpi=200;&lt;BR /&gt;ods graphics / reset imagename='SAS94M2_ForestPlot_GTL';&lt;/P&gt;
&lt;P&gt;proc sgrender data=forest2 template=forestAxisTable;&lt;BR /&gt; dynamic _bandColor='cxf0f0f0' _headerColor='cxd0d0d0';&lt;BR /&gt;run;&lt;BR /&gt;ods _all_ close;&lt;/P&gt;</description>
      <pubDate>Thu, 05 May 2016 14:25:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/A-problem-of-row-space-in-the-forest-plot/m-p/268546#M9616</guid>
      <dc:creator>Jay54</dc:creator>
      <dc:date>2016-05-05T14:25:01Z</dc:date>
    </item>
    <item>
      <title>Re: A problem of row space in the forest plot</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/A-problem-of-row-space-in-the-forest-plot/m-p/268570#M9617</link>
      <description>&lt;P&gt;Hi Sanjay,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks so much! &amp;nbsp;This is really helpful, I've learned a lot.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;best regards,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Jay&lt;/P&gt;</description>
      <pubDate>Thu, 05 May 2016 15:13:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/A-problem-of-row-space-in-the-forest-plot/m-p/268570#M9617</guid>
      <dc:creator>JayL</dc:creator>
      <dc:date>2016-05-05T15:13:11Z</dc:date>
    </item>
  </channel>
</rss>

