<?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: SGPLOT Refline have placed incorrecctly in ODS and Base Reporting</title>
    <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/SGPLOT-Refline-have-placed-incorrecctly/m-p/788601#M25531</link>
    <description>&lt;P&gt;Mar2020 tick-mark on X axis corresponds to 31Mar2020.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 06 Jan 2022 05:05:27 GMT</pubDate>
    <dc:creator>LalitPatel</dc:creator>
    <dc:date>2022-01-06T05:05:27Z</dc:date>
    <item>
      <title>SGPLOT Refline have placed incorrecctly</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/SGPLOT-Refline-have-placed-incorrecctly/m-p/788584#M25529</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have defeind the refline for specific date but it was coming before the date rather than specified.&lt;/P&gt;&lt;P&gt;Below is my output, the refline date is 11MAR2020 , but it was displaye before Mar2020.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="raja777pharma_0-1641432632688.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/67151i1C25E7A4DE39BCEF/image-size/medium?v=v2&amp;amp;px=400" role="button" title="raja777pharma_0-1641432632688.png" alt="raja777pharma_0-1641432632688.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Below&amp;nbsp; is my code.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;data prefinal;
  set indata;
   if fasfl='Y';
   cutoff=cov19pdt;    
   adt = FUPEDT;
      
   if randdt &amp;gt; cutoff then do;
     adt2=adt;
     randdt2=randdt;
     before='Y';
   end;
   else if adt &amp;lt; cutoff then do;
     adt1=adt;
     randdt1=randdt;
     after='Y';
   end;
   else do;
     randdt1=randdt;
     adt1=cutoff;
     randdt2=cutoff;
     adt2=adt;
     both='Y';
   end;   
   format  randdt randdt1 adt randdt2 adt2 cutoff date9. ;        
   keep usubjid randdt1 adt1 randdt2 adt2 cutoff randdt adt fupedt;
run;

proc sql noprint ;
  create table xaxisdt as
  select min(randdt) as xstdt format date9.
        ,max(adt) as xendt format date9.
        ,max(cutoff) as cutoffdt format date9.
  from prefinal;
quit;

data xaxisdt;
  set xaxisdt;
  stdtn=intnx('month',xstdt,-1,'s');
  stdtc=put(stdtn,date9.);  
  endtn=intnx('month',xendt,1,'s');
  endtc=put(endtn,date9.);
  
  keep stdtc endtc cutoffdt;
run;

proc sql noprint;
  select stdtc,endtc ,cutoffdt into: xstdt, :xendt, :cutoffdt
  from xaxisdt;
quit;

proc sgplot data=final;
       highlow Y=N low=RANDDT1 high=ADT1/lineattrs=(thickness=1.5 pattern=solid color=grey) name='C' legendlabel='Follow-up Days';
       highlow Y=N low=RANDDT2 high=ADT2/lineattrs=(thickness=1.5 pattern=solid color=charcoal) name='C' legendlabel='Follow-up Days';
       yaxis label="Subjects (N = %trim(&amp;amp;n99))"  values=(0 1000 2000 3000 4000 5000 6000 6500);
       xaxis label="Study Calendar" interval=quarter VALUESFORMAT=MONYY7.;
       refline "&amp;amp;cutoffdt."d/ axis=x  lineattrs=(thickness=3 pattern=dash color=black) label="&amp;amp;cutoffdt. (COVID-19 Pandemic Date)";
       
        inset "%trim(&amp;amp;nbe)% Of follow-up days prior to the start of COVID-19 pandemic" / position=left textattrs=(color=black  size=9);
        inset "%trim(&amp;amp;ndu)% Of follow-up days after or on the start of COVID-19 pandemic" / position=right textattrs=(color=black  size=9); 
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Also please let me know how we can wrap inset text.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you,&lt;/P&gt;&lt;P&gt;Rajasekahar B&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 06 Jan 2022 01:36:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/SGPLOT-Refline-have-placed-incorrecctly/m-p/788584#M25529</guid>
      <dc:creator>raja777pharma</dc:creator>
      <dc:date>2022-01-06T01:36:18Z</dc:date>
    </item>
    <item>
      <title>Re: SGPLOT Refline have placed incorrecctly</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/SGPLOT-Refline-have-placed-incorrecctly/m-p/788590#M25530</link>
      <description>Show the value of the cutoff date macro variable.</description>
      <pubDate>Thu, 06 Jan 2022 03:51:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/SGPLOT-Refline-have-placed-incorrecctly/m-p/788590#M25530</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2022-01-06T03:51:44Z</dc:date>
    </item>
    <item>
      <title>Re: SGPLOT Refline have placed incorrecctly</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/SGPLOT-Refline-have-placed-incorrecctly/m-p/788601#M25531</link>
      <description>&lt;P&gt;Mar2020 tick-mark on X axis corresponds to 31Mar2020.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 06 Jan 2022 05:05:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/SGPLOT-Refline-have-placed-incorrecctly/m-p/788601#M25531</guid>
      <dc:creator>LalitPatel</dc:creator>
      <dc:date>2022-01-06T05:05:27Z</dc:date>
    </item>
    <item>
      <title>Re: SGPLOT Refline have placed incorrecctly</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/SGPLOT-Refline-have-placed-incorrecctly/m-p/788640#M25532</link>
      <description>If you want "wrap inset text." ,try multiple quote for INSET.&lt;BR /&gt;&lt;BR /&gt;proc sgplot data=sashelp.class;&lt;BR /&gt;       scatter x=weight y=height/datalabel=name group=sex;&lt;BR /&gt;        inset "%trim(&amp;amp;nbe)% Of follow-up days"   "prior to the start of COVID-19 pandemic" / position=left textattrs=(color=black  size=9);&lt;BR /&gt;        inset "%trim(&amp;amp;ndu)% Of follow-up days"   "after or on the start of COVID-19 pandemic" / position=right textattrs=(color=black  size=9); &lt;BR /&gt;run;</description>
      <pubDate>Thu, 06 Jan 2022 12:13:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/SGPLOT-Refline-have-placed-incorrecctly/m-p/788640#M25532</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2022-01-06T12:13:01Z</dc:date>
    </item>
    <item>
      <title>Re: SGPLOT Refline have placed incorrecctly</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/SGPLOT-Refline-have-placed-incorrecctly/m-p/788642#M25533</link>
      <description>&lt;P&gt;cutoff maccro variable resolve to 11Mar2020 and date formate in data set is date9.&lt;BR /&gt;&lt;BR /&gt;Thank you,&lt;BR /&gt;Rajasekhar Reddy.&lt;/P&gt;</description>
      <pubDate>Thu, 06 Jan 2022 12:26:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/SGPLOT-Refline-have-placed-incorrecctly/m-p/788642#M25533</guid>
      <dc:creator>raja777pharma</dc:creator>
      <dc:date>2022-01-06T12:26:42Z</dc:date>
    </item>
    <item>
      <title>Re: SGPLOT Refline have placed incorrecctly</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/SGPLOT-Refline-have-placed-incorrecctly/m-p/788643#M25534</link>
      <description>How we can create tick values for starting of the month, i,e 01Mar2020</description>
      <pubDate>Thu, 06 Jan 2022 12:25:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/SGPLOT-Refline-have-placed-incorrecctly/m-p/788643#M25534</guid>
      <dc:creator>raja777pharma</dc:creator>
      <dc:date>2022-01-06T12:25:41Z</dc:date>
    </item>
    <item>
      <title>Re: SGPLOT Refline have placed incorrecctly</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/SGPLOT-Refline-have-placed-incorrecctly/m-p/788655#M25535</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I think the problem is that your plot has a linear axis rather than a time axis.&amp;nbsp; To fix it, make sure randdt1 randdt2 addt1 addt2 all have date formats attached to them in work.final (you could add a format statement inside the SGPLOT).&amp;nbsp; This should trigger SGPLOT to use a time axis.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;One warning sign in your picture is that the month names are not the start of a quarter (they should be Jan, Apr, Jul, Oct).&amp;nbsp; The easiest way to confirm this problem is to change the xaxis to valuesformat=date9.&amp;nbsp; It should show you that the day values for each month are not the first or the last of the month, because it's a linear axis I think the start point is driven by the data.&amp;nbsp; I'm surprised that SGPLOT doesn't throw at least a NOTE to say that you are using a time interval for a linear axis.&amp;nbsp; I thought you could fix this by adding type=time to the axis statement, but SAS then throws a note that although you have requested a time axis, the axis will be changed to linear because the values being plotted are not time values.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So in order to get a proper time axis, it looks like the values need to be formatted as dates (or date-times or times) so SGPLOT knows it is plotting time values.&amp;nbsp; Then SGPLOT will give you a time axis rather than a linear axis.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Sample code below.&amp;nbsp; It's always helpful to make a tiny test case when exploring SAS questions, so that you can narrow down the problem.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have ;
  do randdt1="01Jan2020"d to "01Jan2021"d by 10 ;
    randdt2=randdt1+100 ;
    N++1 ;
    output ;
  end ;
run ;


title1 "This plot has a linear axis rather than a time axis because the variables are not formatted as dates" ;
proc sgplot data=have ;
  highlow y=N low=randdt1 high=randdt2;
  refline "11Mar2020"d /axis=x ;
  xaxis interval=quarter  valuesformat=mmddyy10. ;
run ;
title1 ;

title1 "This plot has a time axis because randdt1 and randdt2 have a date format attached" ;
proc sgplot data=have ;
  highlow y=N low=randdt1 high=randdt2;
  refline "11Mar2020"d /axis=x ;
  xaxis interval=quarter  valuesformat=mmddyy10. ;
  format randdt1 randdt2 date9. ;
run ;
title1 ;

title1 "This plot has a time axis because randdt1 and randdt2 have a date format attached" ;
proc sgplot data=have ;
  highlow y=N low=randdt1 high=randdt2;
  refline "11Mar2020"d /axis=x ;
  xaxis interval=quarter  valuesformat=monyy7. ;
  format randdt1 randdt2 date9. ;
run ;
title1 ;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 06 Jan 2022 14:01:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/SGPLOT-Refline-have-placed-incorrecctly/m-p/788655#M25535</guid>
      <dc:creator>Quentin</dc:creator>
      <dc:date>2022-01-06T14:01:20Z</dc:date>
    </item>
  </channel>
</rss>

