<?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: Why does SGPLOT not use a custom format correctly? in Graphics Programming</title>
    <link>https://communities.sas.com/t5/Graphics-Programming/Why-does-SGPLOT-not-use-a-custom-format-correctly/m-p/806243#M22729</link>
    <description>&lt;P&gt;From Googling this problem, it looks like others have reported similar behavior. See&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://stackoverflow.com/questions/34227288/sas-proc-sgplot-with-date-axis-formatted-as-m-d-yy-i-e-without-leading-zeros" target="_blank"&gt;formatting - SAS proc sgplot with date axis formatted as m/d/yy (i.e. without leading zeros) - Stack Overflow&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;First, I think you will have more success by keeping a native SAS format. Otherwise, the X axis doesn't know how to handle the spacing for the dates. Remove the FORMAT statement and use the&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;XAXIS valuesformat=&amp;nbsp;&lt;BR /&gt;&lt;/STRONG&gt;option to supply a custom format.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Second, it looks like the VALUESFORMAT= option does not work with a PICTURE format, so unfortunately you cannot use&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;xaxis valuesformat=myqtr.;&amp;nbsp; /* does not work with PICTURE format */&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;I believe it works for other custom formats, but I have not tested it. Try creating your desired format by using a conventional VALUE statement in PROC FORMAT or by defining an FCMP function.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 06 Apr 2022 10:21:08 GMT</pubDate>
    <dc:creator>Rick_SAS</dc:creator>
    <dc:date>2022-04-06T10:21:08Z</dc:date>
    <item>
      <title>Why does SGPLOT not use a custom format correctly?</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Why-does-SGPLOT-not-use-a-custom-format-correctly/m-p/806228#M22727</link>
      <description>&lt;P&gt;Consider this picture format:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc format;
picture myqtr (default=6)
  low-high='%q%Y' (datatype=date)
;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;applied to this dataset:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
infile datalines dlm="09"x;
input phase $ patients qtr :yymmdd10.;
format qtr myqtr.;
datalines;
I	5	2021-01-01	
I	10	2021-04-01	
I	14	2021-07-01	
I	8	2022-01-01	
II	20	2021-01-01	
II	30	2021-04-01	
II	66	2021-07-01	
II	55	2022-01-01	
III	60	2021-01-01	
III	70	2021-04-01	
III	78	2021-07-01	
III	67	2022-01-01
;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;In the dataset, the dates show nicely as (e.g) Q12021&lt;/P&gt;
&lt;P&gt;Now I run PROC SGPLOT:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sgplot data=have;
label
  patients = "Patients"
  qtr = "Quarter"
;
vline qtr / response=patients group=phase;
yaxis grid;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;and I get this:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="SGPLOT1.png"&gt;&lt;img src="https://communities.sas.com/skins/images/E0BB18E7DAA53C21BC28740CEA0E38DA/responsive_peak/images/image_not_found.png" alt="SGPLOT1.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Just the format string is used as value.&lt;/P&gt;
&lt;P&gt;But when I change the format to a standard SAS format:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sgplot data=have;
format qtr yyq7.;
label
  patients = "Patients"
  qtr = "Quarter"
;
vline qtr / response=patients group=phase;
yaxis grid;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I get this:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="SGPLOT2.png"&gt;&lt;img src="https://communities.sas.com/skins/images/E0BB18E7DAA53C21BC28740CEA0E38DA/responsive_peak/images/image_not_found.png" alt="SGPLOT2.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Does SGPLOT have an issue with custom formats?&lt;/P&gt;</description>
      <pubDate>Wed, 06 Apr 2022 09:25:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Why-does-SGPLOT-not-use-a-custom-format-correctly/m-p/806228#M22727</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2022-04-06T09:25:13Z</dc:date>
    </item>
    <item>
      <title>Re: Why does SGPLOT not use a custom format correctly?</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Why-does-SGPLOT-not-use-a-custom-format-correctly/m-p/806239#M22728</link>
      <description>&lt;P&gt;Found it. The Graph Template Language cannot deal with the directives of a date, time or datetime picture format:&lt;/P&gt;
&lt;P&gt;&lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/grstatgraph/p0mwk2su1mw8bnn1f6xonfde64h5.htm" target="_blank" rel="noopener"&gt;Unsupported User-Defined Formats&lt;/A&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 06 Apr 2022 10:03:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Why-does-SGPLOT-not-use-a-custom-format-correctly/m-p/806239#M22728</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2022-04-06T10:03:44Z</dc:date>
    </item>
    <item>
      <title>Re: Why does SGPLOT not use a custom format correctly?</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Why-does-SGPLOT-not-use-a-custom-format-correctly/m-p/806243#M22729</link>
      <description>&lt;P&gt;From Googling this problem, it looks like others have reported similar behavior. See&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://stackoverflow.com/questions/34227288/sas-proc-sgplot-with-date-axis-formatted-as-m-d-yy-i-e-without-leading-zeros" target="_blank"&gt;formatting - SAS proc sgplot with date axis formatted as m/d/yy (i.e. without leading zeros) - Stack Overflow&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;First, I think you will have more success by keeping a native SAS format. Otherwise, the X axis doesn't know how to handle the spacing for the dates. Remove the FORMAT statement and use the&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;XAXIS valuesformat=&amp;nbsp;&lt;BR /&gt;&lt;/STRONG&gt;option to supply a custom format.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Second, it looks like the VALUESFORMAT= option does not work with a PICTURE format, so unfortunately you cannot use&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;xaxis valuesformat=myqtr.;&amp;nbsp; /* does not work with PICTURE format */&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;I believe it works for other custom formats, but I have not tested it. Try creating your desired format by using a conventional VALUE statement in PROC FORMAT or by defining an FCMP function.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 06 Apr 2022 10:21:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Why-does-SGPLOT-not-use-a-custom-format-correctly/m-p/806243#M22729</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2022-04-06T10:21:08Z</dc:date>
    </item>
    <item>
      <title>Re: Why does SGPLOT not use a custom format correctly?</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Why-does-SGPLOT-not-use-a-custom-format-correctly/m-p/806244#M22730</link>
      <description>&lt;P&gt;Custom formats work, but not picture formats that use directives. I have not looked into this, but I suspect that the directive notation would interfere with the GTL syntax (the % character is the usual suspect here).&lt;/P&gt;</description>
      <pubDate>Wed, 06 Apr 2022 10:23:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Why-does-SGPLOT-not-use-a-custom-format-correctly/m-p/806244#M22730</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2022-04-06T10:23:58Z</dc:date>
    </item>
    <item>
      <title>Re: Why does SGPLOT not use a custom format correctly?</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Why-does-SGPLOT-not-use-a-custom-format-correctly/m-p/806245#M22731</link>
      <description>&lt;P&gt;Native formats are no problem at all, but a user wanted to have a different notation of quarters that is not covered by a standard SAS format, see in this thread:&amp;nbsp;&lt;A href="https://communities.sas.com/t5/SAS-Programming/How-to-depict-quarters-of-the-year-on-the-x-axis/td-p/806000/jump-to/first-unread-message" target="_blank" rel="noopener"&gt;https://communities.sas.com/t5/SAS-Programming/How-to-depict-quarters-of-the-year-on-the-x-axis/td-p/806000/jump-to/first-unread-message&lt;/A&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It would still be nice, though, to have all elements in SAS treat all formats the same, consistently. After all, it took me (and I'm no SAS newbie) considerable effort to find the reason for the non-function. And, IMHO, as a customer of SAS one would expect the software to be consistent throughout with the use of formats. I consider this expectance part of the big bucks people pay for SAS.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;PS Da haben sich die Designer nicht mit Ruhm bekleckert.&lt;/P&gt;
&lt;P&gt;("The designers did not exactly cover themselves with glory")&lt;/P&gt;</description>
      <pubDate>Wed, 06 Apr 2022 10:36:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Why-does-SGPLOT-not-use-a-custom-format-correctly/m-p/806245#M22731</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2022-04-06T10:36:47Z</dc:date>
    </item>
    <item>
      <title>Re: Why does SGPLOT not use a custom format correctly?</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Why-does-SGPLOT-not-use-a-custom-format-correctly/m-p/806304#M22733</link>
      <description>&lt;P&gt;I might suggest using a function created in FCMP to produce a string value for the target of a format.&lt;/P&gt;
&lt;P&gt;Of course that adds another level of headache to code maintenance but the things we do for customers...&lt;/P&gt;</description>
      <pubDate>Wed, 06 Apr 2022 14:36:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Why-does-SGPLOT-not-use-a-custom-format-correctly/m-p/806304#M22733</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2022-04-06T14:36:57Z</dc:date>
    </item>
  </channel>
</rss>

