<?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: Adjusting the auto format of tick values on times axes in SGPLOT in Graphics Programming</title>
    <link>https://communities.sas.com/t5/Graphics-Programming/Adjusting-the-auto-format-of-tick-values-on-times-axes-in-SGPLOT/m-p/792311#M22529</link>
    <description>&lt;P&gt;Thanks to everyone. What I ended up doing:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/* Create labels based on data */
proc sql noprint;
select 
    put (datepart(min(date)), nldate.),
    put (datepart(min(date)), yymmdd10.),
    intnx ("dtday", min(date), 0, "B") format=15.,
    put (datepart(min(date)) + 1, yymmdd10.),
    intnx ("dtday", min(date), 1, "B") format=15.
into 
    :titledate trimmed,
    :datelabel1 trimmed,
    :dateref1 trimmed,
    :datelabel2 trimmed,
    :dateref2 trimmed
from demande;
quit;

title "Hydro-Québec";
title2 "Production, depuis le &amp;amp;titledate.";
proc sgplot data=demande;
series x=date y=demandeGW / lineattrs=(thickness=2);
xaxis type=time display=(nolabel) offsetmin=0.05 offsetmax=0.05 valuesformat=tod2. ;
yaxis offsetmin=0.05 offsetmax=0.05;
refline &amp;amp;dateref1. &amp;amp;dateref2. / 
    axis=x lineattrs=(pattern=dot) labelloc=inside labelpos=min 
    label=("&amp;amp;datelabel1." "&amp;amp;datelabel2.") labelattrs=(size=8);
refline 20 to 40 by 1 / axis=y;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="PGStats_0-1643141747251.png" style="width: 999px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/67819i72056DA3192496BF/image-size/large?v=v2&amp;amp;px=999" role="button" title="PGStats_0-1643141747251.png" alt="PGStats_0-1643141747251.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I won't mark my own answer as a solution, since it is close but not quite what I wanted, i.e. automatic tick labels on two lines outside the data frame without the ":00:00".&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Btw the INTERVAL=HOUR option created full &lt;EM&gt;date:hour&lt;/EM&gt; tick labels on a single line.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="PGStats_1-1643142769053.png" style="width: 999px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/67820i9A99992C2E7016A5/image-size/large?v=v2&amp;amp;px=999" role="button" title="PGStats_1-1643142769053.png" alt="PGStats_1-1643142769053.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 25 Jan 2022 20:36:04 GMT</pubDate>
    <dc:creator>PGStats</dc:creator>
    <dc:date>2022-01-25T20:36:04Z</dc:date>
    <item>
      <title>Adjusting the auto format of tick values on times axes in SGPLOT</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Adjusting-the-auto-format-of-tick-values-on-times-axes-in-SGPLOT/m-p/791674#M22502</link>
      <description>&lt;P&gt;Hi, I have the following code&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;title "Hydro-Québec";
title2 "Production";
proc sgplot data=demande;
series x=date y=demandeGW / lineattrs=(thickness=2);
xaxis type=time display=(nolabel) offsetmin=0.05 offsetmax=0.05;
yaxis offsetmin=0.05 offsetmax=0.05;
refline 33 to 40 by 1 / axis=y noclip;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Variable &lt;STRONG&gt;date&lt;/STRONG&gt; has DATETIME. format. I like the resulting output:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="PGStats_0-1642887205176.png" style="width: 999px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/67628i6227F38785CCFFD2/image-size/large?v=v2&amp;amp;px=999" role="button" title="PGStats_0-1642887205176.png" alt="PGStats_0-1642887205176.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;But I would like to get rid of the ":00:00" on the X axis, but to keep the date values on a separate line.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Any ideas?&lt;/P&gt;</description>
      <pubDate>Sat, 22 Jan 2022 21:40:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Adjusting-the-auto-format-of-tick-values-on-times-axes-in-SGPLOT/m-p/791674#M22502</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2022-01-22T21:40:31Z</dc:date>
    </item>
    <item>
      <title>Re: Adjusting the auto format of tick values on times axes in SGPLOT</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Adjusting-the-auto-format-of-tick-values-on-times-axes-in-SGPLOT/m-p/791677#M22503</link>
      <description>&lt;P&gt;What about a user-defined &lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/proc/p0n990vq8gxca6n1vnsracr6jp2c.htm" target="_blank" rel="noopener"&gt;PICTURE&lt;/A&gt; format in PROC FORMAT? Selecting the DATETIME PICTURE option with the date and time components should get you what you want.&lt;/P&gt;</description>
      <pubDate>Sat, 22 Jan 2022 21:54:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Adjusting-the-auto-format-of-tick-values-on-times-axes-in-SGPLOT/m-p/791677#M22503</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2022-01-22T21:54:05Z</dc:date>
    </item>
    <item>
      <title>Re: Adjusting the auto format of tick values on times axes in SGPLOT</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Adjusting-the-auto-format-of-tick-values-on-times-axes-in-SGPLOT/m-p/791690#M22504</link>
      <description>&lt;P&gt;Thanks &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13976"&gt;@SASKiwi&lt;/a&gt; . Good idea, but it seems like user-defined PICTURE formats are not expanded by proc SGPLOT on TIME axes. I also tried option INTERVAL=HOUR in the hope that it would reduce the displayed resolution of time values - it didn't.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc format;
picture myTime (default=12)
low-high = '%d%b%y %H' (datatype=datetime);
run;

title "Hydro-Québec";
title2 "Production";
proc sgplot data=demande;
series x=date y=demandeGW / lineattrs=(thickness=2);
xaxis type=time display=(nolabel) offsetmin=0.05 offsetmax=0.05 valuesformat=myTime.;
yaxis offsetmin=0.05 offsetmax=0.05;
refline 33 to 40 by 1 / axis=y noclip;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="PGStats_0-1642910113335.png" style="width: 999px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/67631i1A2885DAC492B445/image-size/large?v=v2&amp;amp;px=999" role="button" title="PGStats_0-1642910113335.png" alt="PGStats_0-1642910113335.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 23 Jan 2022 04:02:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Adjusting-the-auto-format-of-tick-values-on-times-axes-in-SGPLOT/m-p/791690#M22504</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2022-01-23T04:02:57Z</dc:date>
    </item>
    <item>
      <title>Re: Adjusting the auto format of tick values on times axes in SGPLOT</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Adjusting-the-auto-format-of-tick-values-on-times-axes-in-SGPLOT/m-p/791692#M22505</link>
      <description>&lt;P&gt;What about GPLOT? Same problem? Have you checked your format with PROC PRINT or similar to confirm it has defined correctly?&lt;/P&gt;</description>
      <pubDate>Sun, 23 Jan 2022 06:01:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Adjusting-the-auto-format-of-tick-values-on-times-axes-in-SGPLOT/m-p/791692#M22505</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2022-01-23T06:01:08Z</dc:date>
    </item>
    <item>
      <title>Re: Adjusting the auto format of tick values on times axes in SGPLOT</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Adjusting-the-auto-format-of-tick-values-on-times-axes-in-SGPLOT/m-p/791704#M22506</link>
      <description>&lt;P&gt;Hi PGStats , Like this ?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;

data have;
do date='21jan2022'd to '22jan2022'd ;
 do time='00:00:00't to '24:00:00't by '01:00:00't;
  datetime=dhms(date,0,0,time);
  v=rand('normal');output;
 end;
end;
format datetime datetime.;
run;


proc sgplot data=have;
series x=datetime y=v / lineattrs=(thickness=2);
xaxis type=linear display=(nolabel) offsetmin=0.05 offsetmax=0.05 
values=('21jan2022:00:00:00'dt to '22jan2022:24:00:00'dt by '12:00:00't)
valuesdisplay=('21jan2022' '21jan2022:12:00:00' '22jan2022'  '22jan2022:12:00:00' '23jan2022')   ;
yaxis offsetmin=0.05 offsetmax=0.05;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Ksharp_0-1642936392732.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/67634i149227F0F08A2E0C/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Ksharp_0-1642936392732.png" alt="Ksharp_0-1642936392732.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 23 Jan 2022 11:13:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Adjusting-the-auto-format-of-tick-values-on-times-axes-in-SGPLOT/m-p/791704#M22506</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2022-01-23T11:13:22Z</dc:date>
    </item>
    <item>
      <title>Re: Adjusting the auto format of tick values on times axes in SGPLOT</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Adjusting-the-auto-format-of-tick-values-on-times-axes-in-SGPLOT/m-p/791872#M22512</link>
      <description>&lt;P&gt;What do you get if you set INTERVAL=HOUR on the XAXIS statement?&lt;/P&gt;</description>
      <pubDate>Mon, 24 Jan 2022 15:05:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Adjusting-the-auto-format-of-tick-values-on-times-axes-in-SGPLOT/m-p/791872#M22512</guid>
      <dc:creator>DanH_sas</dc:creator>
      <dc:date>2022-01-24T15:05:43Z</dc:date>
    </item>
    <item>
      <title>Re: Adjusting the auto format of tick values on times axes in SGPLOT</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Adjusting-the-auto-format-of-tick-values-on-times-axes-in-SGPLOT/m-p/792311#M22529</link>
      <description>&lt;P&gt;Thanks to everyone. What I ended up doing:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/* Create labels based on data */
proc sql noprint;
select 
    put (datepart(min(date)), nldate.),
    put (datepart(min(date)), yymmdd10.),
    intnx ("dtday", min(date), 0, "B") format=15.,
    put (datepart(min(date)) + 1, yymmdd10.),
    intnx ("dtday", min(date), 1, "B") format=15.
into 
    :titledate trimmed,
    :datelabel1 trimmed,
    :dateref1 trimmed,
    :datelabel2 trimmed,
    :dateref2 trimmed
from demande;
quit;

title "Hydro-Québec";
title2 "Production, depuis le &amp;amp;titledate.";
proc sgplot data=demande;
series x=date y=demandeGW / lineattrs=(thickness=2);
xaxis type=time display=(nolabel) offsetmin=0.05 offsetmax=0.05 valuesformat=tod2. ;
yaxis offsetmin=0.05 offsetmax=0.05;
refline &amp;amp;dateref1. &amp;amp;dateref2. / 
    axis=x lineattrs=(pattern=dot) labelloc=inside labelpos=min 
    label=("&amp;amp;datelabel1." "&amp;amp;datelabel2.") labelattrs=(size=8);
refline 20 to 40 by 1 / axis=y;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="PGStats_0-1643141747251.png" style="width: 999px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/67819i72056DA3192496BF/image-size/large?v=v2&amp;amp;px=999" role="button" title="PGStats_0-1643141747251.png" alt="PGStats_0-1643141747251.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I won't mark my own answer as a solution, since it is close but not quite what I wanted, i.e. automatic tick labels on two lines outside the data frame without the ":00:00".&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Btw the INTERVAL=HOUR option created full &lt;EM&gt;date:hour&lt;/EM&gt; tick labels on a single line.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="PGStats_1-1643142769053.png" style="width: 999px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/67820i9A99992C2E7016A5/image-size/large?v=v2&amp;amp;px=999" role="button" title="PGStats_1-1643142769053.png" alt="PGStats_1-1643142769053.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 25 Jan 2022 20:36:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Adjusting-the-auto-format-of-tick-values-on-times-axes-in-SGPLOT/m-p/792311#M22529</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2022-01-25T20:36:04Z</dc:date>
    </item>
  </channel>
</rss>

