title: SAS Gplot overlay line plots
body: <p>I am trying to plot two sets of line graphs on the same chart:</p>
  
  <pre><code>    /* make data */
  
  data test ;
   do i = 1 to 2 ;
     do x = 1 to 5 ; 
        y = i*x ;
        z = 0.5*i*x ;
   output;
     end ;
   end ;
   run ;
  
   data test ;
   set test ;
   if i =1 then y = -1*y ;
   if i =1 then z = -1*z ;
   run ;
  
  /* set graph style */
  
  * X axis *; axis1 order = (0 to 5 by 1)
                    label = ("x" h=1)
                    minor = (number=4)
                    value = (h=1)
                    offset = (0,0);
  * Y axis *; axis2 label = ("y/z" j=c h=1)
                    minor = (number=1)
                    value = (h=1)
                    offset = (0,0);
  
  symbol1 color=BL interpol=join width=1.25 value="" line=20;
  symbol2 color=VIB interpol=join width=1.25 value="" line=1;
  
  legend1 position=(top right inside)
          value=("y" "z") 
          label=(position=top justify=center 'Var')                                                                                                                      
          across=1;
  
  /* plot */
  
   proc gplot data=test;                                                                                                                 
     plot y*x z*x / overlay noframe vaxis=axis2 haxis=axis1 autovref legend=legend1
                                   cvref=ltgray autohref chref=ltgray lhref=33 lvref=33;                                                                                                   
     where i in (1,2) ;                                                                                                               
  run;                                                                                                                                    
  quit;
  </code></pre>
  
  <p>I can plot the data for either i=1 or i=2 without problems, but when I try to plot the two series on the same graph, two extra lines appear (highlighted with badly drawn arrows below) which link the last value of the series i=1 with the first values of i=2.</p>
  
  <p><img src="https://i.stack.imgur.com/oFbe4.png" alt="enter image description here"></p>
  
  <p>How can I prevent this from happening?</p>