<?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 Re: Bandplot Produces Extra Diagonal Lines in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Bandplot-Produces-Extra-Diagonal-Lines/m-p/862045#M340487</link>
    <description>&lt;P&gt;The reason it is working for PROC SGPLOT is because you are using the GROUP=Early_Onset option. which tells the graph to draw separate curves for each level of the Early_Onset variable.&lt;/P&gt;
&lt;P&gt;In the GTL, you are not using that option. Instead you are using two SERIESPLOT statements and two BANDPLOT statements. But the template will render all observations, which is why the curve jumps from the upper to the lower curve.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The easiest solution is to rewrite the GTL to use a GROUP variable. The (more complicated) solution is to reshape the data from long to wide format. If you do that, you will need the variables (year1, upper1, lower1) for one curve &amp;amp; band and the variables&amp;nbsp;(year2, upper2, lower2) for the second curve &amp;amp; band.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 02 Mar 2023 21:51:16 GMT</pubDate>
    <dc:creator>Rick_SAS</dc:creator>
    <dc:date>2023-03-02T21:51:16Z</dc:date>
    <item>
      <title>Bandplot Produces Extra Diagonal Lines</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Bandplot-Produces-Extra-Diagonal-Lines/m-p/861870#M340416</link>
      <description>&lt;P&gt;I am trying to plot two regression curves with 95% CIs in separate rows by specifying a lattice layout. The issue I am having is that I am getting extra diagonal lines. I think the problem is potentially similar to a question posted by user ammarhm titled: 'strange behaviour of proc lifetest with strata'. However, I am no programmer, and this is my first time delving into GTL language. I am using SAS v 9.04.01M7P080520. The sample dataset I am using is below:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data WORK.WANT3;&lt;BR /&gt;infile datalines dsd truncover;&lt;BR /&gt;input year:BEST12. early_onset:32. new_rate:32. upper_limit:32. lower_limit:32.;&lt;BR /&gt;format year BEST12.;&lt;BR /&gt;datalines;&lt;BR /&gt;1995 0 0.0043981047 0.0044372753 0.0043592798&lt;BR /&gt;1995 1 0.0002554513 0.0002593269 0.0002516337&lt;BR /&gt;1996 0 0.0042431229 0.0042786876 0.0042078538&lt;BR /&gt;1996 1 0.0002464496 0.0002501219 0.0002428313&lt;BR /&gt;1997 0 0.0040936025 0.0041258304 0.0040616262&lt;BR /&gt;1997 1 0.0002377652 0.000241249 0.0002343317&lt;BR /&gt;1998 0 0.0039493508 0.0039785069 0.0039204085&lt;BR /&gt;1998 1 0.0002293867 0.0002326962 0.0002261244&lt;BR /&gt;1999 0 0.0038101824 0.0038365289 0.0037840168&lt;BR /&gt;1999 1 0.0002213035 0.000224452 0.0002181993&lt;BR /&gt;2000 0 0.003675918 0.0036997174 0.0036522718&lt;BR /&gt;2000 1 0.0002135052 0.0002165053 0.0002105466&lt;BR /&gt;2001 0 0.0035463849 0.0035679017 0.0035249979&lt;BR /&gt;2001 1 0.0002059816 0.0002088454 0.0002031571&lt;BR /&gt;2002 0 0.0034214163 0.0034409194 0.0034020238&lt;BR /&gt;2002 1 0.0001987232 0.000201462 0.0001960216&lt;BR /&gt;2003 0 0.0033008514 0.0033186155 0.0032831824&lt;BR /&gt;2003 1 0.0001917205 0.0001943449 0.0001891316&lt;BR /&gt;2004 0 0.003184535 0.0032008409 0.0031683122&lt;BR /&gt;2004 1 0.0001849646 0.0001874845 0.0001824785&lt;BR /&gt;2005 0 0.0030723174 0.0030874495 0.0030572594&lt;BR /&gt;2005 1 0.0001784468 0.0001808715 0.0001760545&lt;BR /&gt;2006 0 0.0029640541 0.0029782953 0.0029498811&lt;BR /&gt;2006 1 0.0001721586 0.0001744968 0.0001698517&lt;BR /&gt;2007 0 0.0028596059 0.0028732286 0.0028460478&lt;BR /&gt;2007 1 0.000166092 0.0001683516 0.0001638628&lt;BR /&gt;2008 0 0.0027588382 0.0027720945 0.0027456454&lt;BR /&gt;2008 1 0.0001602392 0.0001624275 0.0001580805&lt;BR /&gt;2009 0 0.0026616214 0.0026747329 0.0026485743&lt;BR /&gt;2009 1 0.0001545927 0.0001567162 0.0001524979&lt;BR /&gt;2010 0 0.0025678304 0.0025809815 0.0025547464&lt;BR /&gt;2010 1 0.0001491451 0.00015121 0.0001471083&lt;BR /&gt;2011 0 0.0024773444 0.0024906803 0.00246408&lt;BR /&gt;2011 1 0.0001438895 0.0001459013 0.0001419054&lt;BR /&gt;2012 0 0.002390047 0.002403675 0.0023764963&lt;BR /&gt;2012 1 0.000138819 0.0001407826 0.0001368828&lt;BR /&gt;2013 0 0.0023058258 0.0023198202 0.0022919158&lt;BR /&gt;2013 1 0.0001339273 0.000135847 0.0001320347&lt;BR /&gt;2014 0 0.0022245724 0.0022389798 0.0022102577&lt;BR /&gt;2014 1 0.0001292079 0.0001310877 0.0001273551&lt;BR /&gt;2015 0 0.0021461822 0.0021610274 0.0021314391&lt;BR /&gt;2015 1 0.0001246549 0.0001264981 0.0001228385&lt;BR /&gt;2016 0 0.0020705544 0.0020858452 0.0020553758&lt;BR /&gt;2016 1 0.0001202622 0.0001220718 0.0001184794&lt;BR /&gt;2017 0 0.0019975916 0.0020133231 0.001981983&lt;BR /&gt;2017 1 0.0001160244 0.000117803 0.0001142726&lt;BR /&gt;2018 0 0.0019271999 0.001943358 0.001911176&lt;BR /&gt;2018 1 0.0001119359 0.0001136858 0.0001102129&lt;BR /&gt;;;;;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Running the following code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;proc sort data = want3; by year early_onset; run;
proc template;
   define style Styles.MyGrids;
      parent=styles.statistical;
      class GraphGridLines /
         displayopts = "on"
         linethickness = 1px
         linestyle = 1
         contrastcolor = GraphColors('ggrid')
         color = GraphColors('ggrid'); class GraphData1 /
          contrastcolor=blue linestyle=1;
    class GraphData2 /
          contrastcolor=RED linestyle=1;
   end;
run;



proc template;
 define statgraph test;
 begingraph / AXISLINEEXTENT=DATA;
 layout lattice / rows=2 rowweights=(.7 .3) rowgutter=5;
 SIDEBAR / align=bottom;
     discretelegend "Early" "Late";
ENDSIDEBAR;
         layout Overlay / walldisplay=none
		xaxisopts= (display=none linearopts=(viewmin=1995 viewmax=2018
tickvaluesequence=(start=1995 end=2018 increment=5)) griddisplay=on)
                       yaxisopts=(display=(ticks tickvalues) griddisplay=on
                                  linearopts=(viewmin=0.0015 viewmax=0.005 tickvaluesequence=(start=0.0015 end=0.005
increment=0.001)) label=" ");
bandplot x=year limitupper=upper_limit
          limitlower=lower_limit/

name="band" modelname="want3"
legendlabel="Late Onset" name="Late";
seriesplot x=year y=new_rate/ curvelabel="Late" primary=true
lineattrs=GraphData1;
endlayout;
layout overlay / walldisplay=none
xaxisopts=(display=(ticks tickvalues) linearopts=(viewmin=1995 viewmax=2018 tickvaluesequence=(start=1995
end=2018 increment=5)) griddisplay=on)
                       yaxisopts=(display=(ticks tickvalues) griddisplay=on
                                  linearopts=(viewmin=0 viewmax=0.0005 tickvaluesequence=(start=0 end=0.0005
increment=0.00025)) label=" ");
bandplot x=year limitupper=upper_limit

          limitlower=lower_limit/
          fillattrs=(color=red)
		  outlineattrs=(color=red)
name="band" modelname="want3"
          legendlabel="Early Onset" name="Early";
   seriesplot x=year y=new_rate / curvelabel="Early" primary=true
lineattrs=GraphData2;    
endlayout;
endlayout;
endgraph;
end;
run;
								  
ods graphics on/ attrpriority=none;
ods listing gpath="Downloads";
ods listing style=MyGrids;
proc sgrender data=want3 template=test;
 run;
 ods graphics off;
ods _all_ close;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I get the resulting ugly plot&amp;nbsp;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="SGRender39.png" style="width: 640px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/81003i0EDA43882200EEE8/image-size/large?v=v2&amp;amp;px=999" role="button" title="SGRender39.png" alt="SGRender39.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Weirdly, if I run the sgplot procedure, the resulting plot looks fine. The reason I want to use the v.9.4 GTL language is that I want to control the proportion of space occupied by each plot.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;SGPLOT Code:&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;ods graphics on/ attrpriority=none;
ods listing gpath="Downloads";
ods listing style=mygrids;
proc sgplot data=want3;
styleattrs datalinepatterns=(solid) axisbreak=spark axisextent=data ;
legenditem type=markerline name="0" /
      label="Late" lineattrs=GraphData1 markerattrs=GraphData1;
legenditem type=markerline name="1" /
      label="Early" lineattrs=GraphData2 markerattrs=GraphData2;
keylegend "0" "1"/ title="Onset";
band x=Year lower=Lower_Limit upper=Upper_Limit / group=Early_Onset transparency=0.75;
   series x=Year y=new_rate / group=Early_onset curvelabel;
yaxis ranges=(min-0.0005 0.0015-max) values=(0 to 0.0005 by 0.0005 0.0015 to 0.005 by 0.001) valueshint;
 run;
ods _all_ close;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Any help would be greatly appreciated!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Gratefully,&lt;/P&gt;&lt;P&gt;Crow&lt;/P&gt;</description>
      <pubDate>Wed, 01 Mar 2023 23:43:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Bandplot-Produces-Extra-Diagonal-Lines/m-p/861870#M340416</guid>
      <dc:creator>Crowasaurus</dc:creator>
      <dc:date>2023-03-01T23:43:25Z</dc:date>
    </item>
    <item>
      <title>Re: Bandplot Produces Extra Diagonal Lines</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Bandplot-Produces-Extra-Diagonal-Lines/m-p/862045#M340487</link>
      <description>&lt;P&gt;The reason it is working for PROC SGPLOT is because you are using the GROUP=Early_Onset option. which tells the graph to draw separate curves for each level of the Early_Onset variable.&lt;/P&gt;
&lt;P&gt;In the GTL, you are not using that option. Instead you are using two SERIESPLOT statements and two BANDPLOT statements. But the template will render all observations, which is why the curve jumps from the upper to the lower curve.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The easiest solution is to rewrite the GTL to use a GROUP variable. The (more complicated) solution is to reshape the data from long to wide format. If you do that, you will need the variables (year1, upper1, lower1) for one curve &amp;amp; band and the variables&amp;nbsp;(year2, upper2, lower2) for the second curve &amp;amp; band.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 02 Mar 2023 21:51:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Bandplot-Produces-Extra-Diagonal-Lines/m-p/862045#M340487</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2023-03-02T21:51:16Z</dc:date>
    </item>
    <item>
      <title>Re: Bandplot Produces Extra Diagonal Lines</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Bandplot-Produces-Extra-Diagonal-Lines/m-p/862374#M340640</link>
      <description>&lt;P&gt;Thanks Rick!&lt;/P&gt;</description>
      <pubDate>Sun, 05 Mar 2023 19:04:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Bandplot-Produces-Extra-Diagonal-Lines/m-p/862374#M340640</guid>
      <dc:creator>Crowasaurus</dc:creator>
      <dc:date>2023-03-05T19:04:57Z</dc:date>
    </item>
  </channel>
</rss>

