<?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 Axis value formating and Axis Tables in Graphics Programming</title>
    <link>https://communities.sas.com/t5/Graphics-Programming/SGPLOT-Axis-value-formating-and-Axis-Tables/m-p/538375#M17837</link>
    <description>&lt;P&gt;Yes, the plotting positions are based on the raw/unformatted values. Similarly, if you add/multiply, or divide the data you are using the raw values.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can use TYPE=DISCRETE if you want to plot the formatted values, like this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sgplot data=test;
   scatter x=x y=y1;
   format y1 1.;
   yaxis type=discrete;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Regarding the axistable, please read the article&lt;A href="https://blogs.sas.com/content/graphicallyspeaking/2017/10/12/advanced-ods-graphics-two-types-axis-tables/" target="_self"&gt; "Advanced ODS Graphics: Two types of axis tables."&lt;/A&gt;&lt;/P&gt;</description>
    <pubDate>Mon, 25 Feb 2019 18:53:48 GMT</pubDate>
    <dc:creator>Rick_SAS</dc:creator>
    <dc:date>2019-02-25T18:53:48Z</dc:date>
    <item>
      <title>SGPLOT Axis value formating and Axis Tables</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/SGPLOT-Axis-value-formating-and-Axis-Tables/m-p/538365#M17836</link>
      <description>&lt;P&gt;Hi everyone,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have noticed some weird behavior with the SGPLOT procedure and I'm hoping someone can provide some information why it is behaving the way it is.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In short, I've found two things&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;Even if you use a format statement in SGPLOT the &lt;U&gt;unformatted values&lt;/U&gt; are plotted&lt;/LI&gt;
&lt;LI&gt;Axistable values use determined using the &lt;U&gt;formatted values&lt;/U&gt; but are plotted to the &lt;U&gt;unformatted values&lt;/U&gt;&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;My conclusion is that the SGPLOT procedure first plots the unformatted values then assigns the formats to them. Is this correct?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I created a toy example to show you what I mean. In the test dataset i have two y variables. y1 ranges from 0 to 1 by .1 and y2 is taking y1 and rounding it to the nearest 0 or 1 (with the use of a format instead of round function).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
   input x y1 ylab $;
datalines;
0 0 zero
1 .1 one
2 .2 two
3 .3 three
4 .4 four
5 .5 five
6 .6 six
7 .7 seven
8 .8 eight
9 .9 nine
10 1 ten
;	

data test;
   set test;
   y2=input(put(y1,1.),1.)); *round values to nearest whole number 0 or 1;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;As we would expect if we do a basic scatter plot we get the expected result.&lt;CODE class=" language-sas"&gt;&lt;BR /&gt;&lt;/CODE&gt;&lt;/P&gt;
&lt;P&gt;&lt;CODE class=" language-sas"&gt;&lt;/CODE&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sgplot data=test;
   scatter x=x y=y1;

   xaxis values=(0 to 10 by 1);
   yaxis values=(0 to 1 by .1);
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;CODE class=" language-sas"&gt;&lt;/CODE&gt;&lt;/P&gt;
&lt;DIV class="branch"&gt;
&lt;DIV&gt;
&lt;DIV class="c"&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-center" image-alt="image.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/27419i32D5F0A5068AEB1C/image-size/medium?v=v2&amp;amp;px=400" role="button" title="image.png" alt="image.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Now here is where my first question comes in. If we apply a 1. format to y1 then any y1 values less than 0.5 will be formated to 0 and everything greater than or equal to 0.5 will be formatted to a value of 1. This is confirmed if you look at variable y2 in the test dataset.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;However if I run the sgplot procedure with a format statement it does not plot the formatted values. &lt;STRONG&gt;Why? (Question 1)&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sgplot data=test;
   scatter x=x y=y1;

   xaxis values=(0 to 10 by 1);
   yaxis values=(0 to 1 by .1);

   format y1 1.;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;As you can see the &lt;U&gt;unformatted value&lt;/U&gt; of y1 is plotted instead of the formatted value. Is this the typical behavior?&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-center" image-alt="image.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/27419i32D5F0A5068AEB1C/image-size/medium?v=v2&amp;amp;px=400" role="button" title="image.png" alt="image.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;On the other hand if I plot y2 (which is pre-formatted in the dataset) then I get the expected plot. Should we get the same plot if we use the 'format y1 1.' statement?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sgplot data=test;
   scatter x=x y=y2;

   xaxis values=(0 to 10 by 1);
   yaxis values=(0 to 1 by .1);
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-center" image-alt="image.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/27420iEFE4D78A3294BC5E/image-size/medium?v=v2&amp;amp;px=400" role="button" title="image.png" alt="image.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Ok thats my first question. Now to my second observation. I will assign the ylab variable to the y variable.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sgplot data=test;
   scatter x=x y=y1;

   xaxis values=(0 to 10 by 1);
   yaxis values=(0 to 1 by .1);

   yaxistable ylab / position=right;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;As expected each y1 value gets assigned the ylab text.&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-center" image-alt="image.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/27421i3EB480271D73A7C2/image-size/medium?v=v2&amp;amp;px=400" role="button" title="image.png" alt="image.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Now here is the weird part. If I add the format statement to the SGPLOT procedure then only two yaxistable labels are assigned (zero and five).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sgplot data=test;
   scatter x=x y=y1;

   xaxis values=(0 to 10 by 1);
   yaxis values=(0 to 1 by .1);

   yaxistable ylab / position=right;

   format y1 1.;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;DIV class="branch"&gt;
&lt;DIV&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-center" image-alt="image.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/27422i819488A034F089C1/image-size/medium?v=v2&amp;amp;px=400" role="button" title="image.png" alt="image.png" /&gt;&lt;/span&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
Based on my understanding of how axistable work, if there are y-axis values with the same value then the axistable will only assign the first label it encounters. If we look at the &lt;STRONG&gt;formatted value&lt;/STRONG&gt; of y1 we see that 'zero' label is first value for y1=0 and 'five' is the value for y1=1. But if you look at the placement of the ylabels is it placing them next to the y-values of 0 and 0.5 (the unformatted values).&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;TABLE class="tg" style="undefined;table-layout: fixed; width: 175px;"&gt;&lt;COLGROUP&gt; &lt;COL style="width: 26.333333px;" /&gt; &lt;COL style="width: 98.333333px;" /&gt; &lt;COL style="width: 50px;" /&gt; &lt;/COLGROUP&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TH class="tg-fymr"&gt;x&lt;/TH&gt;
&lt;TH class="tg-fymr"&gt;y1 formatted&lt;/TH&gt;
&lt;TH class="tg-fymr"&gt;ylab&lt;/TH&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="tg-0pky"&gt;0&lt;/TD&gt;
&lt;TD class="tg-agym"&gt;0&lt;/TD&gt;
&lt;TD class="tg-agym"&gt;zero&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="tg-0pky"&gt;1&lt;/TD&gt;
&lt;TD class="tg-0pky"&gt;0&lt;/TD&gt;
&lt;TD class="tg-0pky"&gt;one&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="tg-0pky"&gt;2&lt;/TD&gt;
&lt;TD class="tg-0pky"&gt;0&lt;/TD&gt;
&lt;TD class="tg-0pky"&gt;two&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="tg-0pky"&gt;3&lt;/TD&gt;
&lt;TD class="tg-0pky"&gt;0&lt;/TD&gt;
&lt;TD class="tg-0pky"&gt;three&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="tg-0pky"&gt;4&lt;/TD&gt;
&lt;TD class="tg-0pky"&gt;0&lt;/TD&gt;
&lt;TD class="tg-0pky"&gt;four&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="tg-0pky"&gt;5&lt;/TD&gt;
&lt;TD class="tg-agym"&gt;1&lt;/TD&gt;
&lt;TD class="tg-agym"&gt;five&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="tg-0pky"&gt;6&lt;/TD&gt;
&lt;TD class="tg-0pky"&gt;1&lt;/TD&gt;
&lt;TD class="tg-0pky"&gt;six&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="tg-0pky"&gt;7&lt;/TD&gt;
&lt;TD class="tg-0pky"&gt;1&lt;/TD&gt;
&lt;TD class="tg-0pky"&gt;seven&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="tg-0pky"&gt;8&lt;/TD&gt;
&lt;TD class="tg-0pky"&gt;1&lt;/TD&gt;
&lt;TD class="tg-0pky"&gt;eight&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="tg-0pky"&gt;9&lt;/TD&gt;
&lt;TD class="tg-0pky"&gt;1&lt;/TD&gt;
&lt;TD class="tg-0pky"&gt;nine&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="tg-0pky"&gt;10&lt;/TD&gt;
&lt;TD class="tg-0pky"&gt;1&lt;/TD&gt;
&lt;TD class="tg-0pky"&gt;ten&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Ok so I get why it is using the 'zero' and 'five' but why is it placing them at the unformatted values of y1? It would seem to me that the proc is using the &lt;STRONG&gt;formatted&lt;/STRONG&gt; values of y1 to &lt;STRONG&gt;determine the appropriate label&lt;/STRONG&gt; to use but &lt;STRONG&gt;plotted the labels&lt;/STRONG&gt; at the &lt;STRONG&gt;unformatted&lt;/STRONG&gt; value.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Lastly if we use plot the pre-formatted value of y2 then the scatter plot is behaving as I would expect (in my mind). It is using the expected labels and plotting them at the correct y-values.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sgplot data=test;
   scatter x=x y=y2;

   xaxis values=(0 to 10 by 1);
   yaxis values=(0 to 1 by .1);

   yaxistable ylab / position=right;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-center" image-alt="image.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/27423iF449EA17D60F3A07/image-size/medium?v=v2&amp;amp;px=400" role="button" title="image.png" alt="image.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 25 Feb 2019 19:06:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/SGPLOT-Axis-value-formating-and-Axis-Tables/m-p/538365#M17836</guid>
      <dc:creator>spirto</dc:creator>
      <dc:date>2019-02-25T19:06:15Z</dc:date>
    </item>
    <item>
      <title>Re: SGPLOT Axis value formating and Axis Tables</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/SGPLOT-Axis-value-formating-and-Axis-Tables/m-p/538375#M17837</link>
      <description>&lt;P&gt;Yes, the plotting positions are based on the raw/unformatted values. Similarly, if you add/multiply, or divide the data you are using the raw values.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can use TYPE=DISCRETE if you want to plot the formatted values, like this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sgplot data=test;
   scatter x=x y=y1;
   format y1 1.;
   yaxis type=discrete;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Regarding the axistable, please read the article&lt;A href="https://blogs.sas.com/content/graphicallyspeaking/2017/10/12/advanced-ods-graphics-two-types-axis-tables/" target="_self"&gt; "Advanced ODS Graphics: Two types of axis tables."&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 25 Feb 2019 18:53:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/SGPLOT-Axis-value-formating-and-Axis-Tables/m-p/538375#M17837</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2019-02-25T18:53:48Z</dc:date>
    </item>
    <item>
      <title>Re: SGPLOT Axis value formating and Axis Tables</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/SGPLOT-Axis-value-formating-and-Axis-Tables/m-p/538383#M17838</link>
      <description>&lt;P&gt;Thanks Rick!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Is there any way to show additional tick marks when using a discrete axis?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;e.g. yaxis type=discrete values=(0 to 1 by .1)&lt;/P&gt;</description>
      <pubDate>Mon, 25 Feb 2019 19:05:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/SGPLOT-Axis-value-formating-and-Axis-Tables/m-p/538383#M17838</guid>
      <dc:creator>spirto</dc:creator>
      <dc:date>2019-02-25T19:05:16Z</dc:date>
    </item>
    <item>
      <title>Re: SGPLOT Axis value formating and Axis Tables</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/SGPLOT-Axis-value-formating-and-Axis-Tables/m-p/538388#M17839</link>
      <description>&lt;P&gt;Actually I found the answer to my own question. For discrete axis you have to enclose the values in quotes e.g. values=("0" "1") but then catch is that "If a numeric variable has an associated format, the specified values must use the same format."&lt;BR /&gt;&lt;BR /&gt;So in my example since we using the 1. format then my values have to also be in that format e.g. "0" "1" "2" "3"&lt;BR /&gt;&lt;BR /&gt;I can't do "0" "0.1" "0.2" "0.3" etc.&lt;/P&gt;</description>
      <pubDate>Mon, 25 Feb 2019 19:17:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/SGPLOT-Axis-value-formating-and-Axis-Tables/m-p/538388#M17839</guid>
      <dc:creator>spirto</dc:creator>
      <dc:date>2019-02-25T19:17:05Z</dc:date>
    </item>
  </channel>
</rss>

