<?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: how plot 2 variables on the same x axis controling the X axis label in sgplot in Graphics Programming</title>
    <link>https://communities.sas.com/t5/Graphics-Programming/how-plot-2-variables-on-the-same-x-axis-controling-the-X-axis/m-p/470656#M16239</link>
    <description>&lt;P&gt;Fantastic!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank very much!&lt;/P&gt;&lt;P&gt;Working perfectlly&lt;/P&gt;</description>
    <pubDate>Fri, 15 Jun 2018 17:13:52 GMT</pubDate>
    <dc:creator>Giovani</dc:creator>
    <dc:date>2018-06-15T17:13:52Z</dc:date>
    <item>
      <title>how plot 2 variables on the same x axis controling the X axis label in sgplot</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/how-plot-2-variables-on-the-same-x-axis-controling-the-X-axis/m-p/470607#M16229</link>
      <description>&lt;P&gt;Hi SAS experts,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to build a series plot in sgplot using X axis as year and week.&lt;/P&gt;&lt;P&gt;when I build the graph in excel it returns a X axis label like this:&amp;nbsp;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="excell.PNG" style="width: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/21208iCDA4841B8F57A5F4/image-size/large?v=v2&amp;amp;px=999" role="button" title="excell.PNG" alt="excell.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;But in SAS it is not possible to read the X Axis&amp;nbsp;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Capture.PNG" style="width: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/21209i3E86C2F635678810/image-size/large?v=v2&amp;amp;px=999" role="button" title="Capture.PNG" alt="Capture.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;The data is organized like this:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Data Cars;&lt;BR /&gt;input&lt;BR /&gt;year $ week $ Small_Size $ Mid_Size $ Large_Size $ Van $&lt;BR /&gt;;&lt;BR /&gt;cards;&lt;BR /&gt;2018 1 10 15 23 16&lt;BR /&gt;2018 2 12 11 28 18&lt;BR /&gt;2018 3 15 19 17 11&lt;BR /&gt;;&lt;BR /&gt;run;&lt;BR /&gt;Data Cars; set cars;&lt;BR /&gt;YearWeek=catx(' ',Year,Week);&lt;BR /&gt;run;&lt;BR /&gt;Data Cars; set cars;&lt;BR /&gt;format YearWeek $7.;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And the SAS codes for the graph that I am using is this:&lt;/P&gt;&lt;P&gt;ods graphics on /&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; width=10 in&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; outputfmt=gif&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; imagemap=on&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; imagename="Cars"&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; border=off;&lt;BR /&gt;&amp;nbsp;&lt;BR /&gt;PROC SGPLOT DATA = Cars;&lt;BR /&gt;&amp;nbsp;SERIES X = YearWeek Y = Small_Size;&lt;BR /&gt;&amp;nbsp;SERIES X = YearWeek Y = Mid_Size;&lt;BR /&gt;&amp;nbsp;SERIES X = YearWeek Y = Large_Size;&lt;BR /&gt;&amp;nbsp;SERIES X = YearWeek Y = Van;&lt;BR /&gt;&amp;nbsp;XAXIS TYPE = DISCRETE GRID;&lt;BR /&gt;&amp;nbsp;YAXIS LABEL = 'Number of cars' GRID VALUES = (5 TO 40 BY 1);&lt;BR /&gt;&amp;nbsp;TITLE 'Sales by type';&lt;BR /&gt;&amp;nbsp;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any suggestion how I could control the X axis to look some how like the one I am getting in excel?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank very much!&lt;/P&gt;</description>
      <pubDate>Fri, 15 Jun 2018 14:21:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/how-plot-2-variables-on-the-same-x-axis-controling-the-X-axis/m-p/470607#M16229</guid>
      <dc:creator>Giovani</dc:creator>
      <dc:date>2018-06-15T14:21:47Z</dc:date>
    </item>
    <item>
      <title>Re: how plot 2 variables on the same x axis controling the X axis label in sgplot</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/how-plot-2-variables-on-the-same-x-axis-controling-the-X-axis/m-p/470610#M16230</link>
      <description>&lt;P&gt;Remove discrete from the xaxis to show fewer tick marks and values.&lt;/P&gt;
&lt;P&gt;Notice that your EXCEL example does not attempt to display each value of week.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 15 Jun 2018 14:31:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/how-plot-2-variables-on-the-same-x-axis-controling-the-X-axis/m-p/470610#M16230</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2018-06-15T14:31:37Z</dc:date>
    </item>
    <item>
      <title>Re: how plot 2 variables on the same x axis controling the X axis label in sgplot</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/how-plot-2-variables-on-the-same-x-axis-controling-the-X-axis/m-p/470615#M16231</link>
      <description>&lt;P&gt;There are two changes I would recommend:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;1. Do not input YEAR and WEEK as character strings. Input them as numbers.&lt;/P&gt;
&lt;P&gt;Change:&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;input&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;year $ week $ Small_Size $ Mid_Size $ Large_Size $ Van $;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;to:&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;input&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;year week Small_Size $ Mid_Size $ Large_Size $ Van $;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;That way, the axis is not forced to discrete, and the axis will thin out naturally for linear numbers. If you really want to keep the axis discrete, keep your TYPE=DISCRETE and add FITPOLICY=THIN. &lt;STRONG&gt;THE&lt;/STRONG&gt; best way to represent this information is using a time axis, but that would require you to turn your year/week values into SAS datatime values.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;2. Instead of using SGPLOT, try using SGPANEL to create the layout you want for this case:&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sgpanel data=cars;
panelby&amp;nbsp;year / noborder layout=COLUMNLATTICE uniscale=row
               onepanel colheaderpos=bottom novarname;
SERIES X =&amp;nbsp;week Y = Small_Size;
&amp;nbsp;SERIES X = week Y = Mid_Size;
&amp;nbsp;SERIES X = week Y = Large_Size;
&amp;nbsp;SERIES X = week Y = Van;
&amp;nbsp;colaxis&amp;nbsp; GRID;
&amp;nbsp;rowaxis LABEL = 'Number of cars' GRID VALUES = (5 TO 40 BY 1);
&amp;nbsp;TITLE 'Sales by type';
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Hope this helps!&lt;/P&gt;
&lt;P&gt;Dan&lt;/P&gt;</description>
      <pubDate>Fri, 15 Jun 2018 14:49:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/how-plot-2-variables-on-the-same-x-axis-controling-the-X-axis/m-p/470615#M16231</guid>
      <dc:creator>DanH_sas</dc:creator>
      <dc:date>2018-06-15T14:49:29Z</dc:date>
    </item>
    <item>
      <title>Re: how plot 2 variables on the same x axis controling the X axis label in sgplot</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/how-plot-2-variables-on-the-same-x-axis-controling-the-X-axis/m-p/470621#M16232</link>
      <description>&lt;P&gt;Dear Dan;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;THANK VERY MUCH!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It worked great. Only one small DETAIL to be perfect.&lt;/P&gt;&lt;P&gt;When change from one year to another there is gap in the graph. Any idea how this could be avoided making the lines to connect each other?&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Capture.PNG" style="width: 410px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/21211iC753BCA0F0E87969/image-size/large?v=v2&amp;amp;px=999" role="button" title="Capture.PNG" alt="Capture.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 15 Jun 2018 15:16:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/how-plot-2-variables-on-the-same-x-axis-controling-the-X-axis/m-p/470621#M16232</guid>
      <dc:creator>Giovani</dc:creator>
      <dc:date>2018-06-15T15:16:01Z</dc:date>
    </item>
    <item>
      <title>Re: how plot 2 variables on the same x axis controling the X axis label in sgplot</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/how-plot-2-variables-on-the-same-x-axis-controling-the-X-axis/m-p/470623#M16233</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/170866"&gt;@Giovani&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Dear Dan;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;THANK VERY MUCH!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It worked great. Only one small DETAIL to be perfect.&lt;/P&gt;
&lt;P&gt;When change from one year to another there is gap in the graph. Any idea how this could be avoided making the lines to connect each other?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Another reason to use an actual DATE value. That would be continuous. Also you can create or apply a format shows tick values with a possibly more intuitive appearance.&lt;/P&gt;</description>
      <pubDate>Fri, 15 Jun 2018 15:22:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/how-plot-2-variables-on-the-same-x-axis-controling-the-X-axis/m-p/470623#M16233</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2018-06-15T15:22:24Z</dc:date>
    </item>
    <item>
      <title>Re: how plot 2 variables on the same x axis controling the X axis label in sgplot</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/how-plot-2-variables-on-the-same-x-axis-controling-the-X-axis/m-p/470626#M16234</link>
      <description>&lt;P&gt;Hi Ballardw,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Removing DISCRETE didn`t correct the issue.&lt;/P&gt;&lt;P&gt;Actually I don`t have the a specific date for the information. I only have the year value and a value for week.&lt;/P&gt;</description>
      <pubDate>Fri, 15 Jun 2018 15:30:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/how-plot-2-variables-on-the-same-x-axis-controling-the-X-axis/m-p/470626#M16234</guid>
      <dc:creator>Giovani</dc:creator>
      <dc:date>2018-06-15T15:30:25Z</dc:date>
    </item>
    <item>
      <title>Re: how plot 2 variables on the same x axis controling the X axis label in sgplot</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/how-plot-2-variables-on-the-same-x-axis-controling-the-X-axis/m-p/470627#M16235</link>
      <description>&lt;P&gt;You can try setting SPACING=0 or SPACING=1 on the PANELBY statement to help with this gap, but ballardw is correct. If you converted year/week to a true datetime value, you can use a time axis in SGPLOT that will give you the look you want (year split from weeks) without the gap.&lt;/P&gt;</description>
      <pubDate>Fri, 15 Jun 2018 15:33:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/how-plot-2-variables-on-the-same-x-axis-controling-the-X-axis/m-p/470627#M16235</guid>
      <dc:creator>DanH_sas</dc:creator>
      <dc:date>2018-06-15T15:33:30Z</dc:date>
    </item>
    <item>
      <title>Re: how plot 2 variables on the same x axis controling the X axis label in sgplot</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/how-plot-2-variables-on-the-same-x-axis-controling-the-X-axis/m-p/470628#M16236</link>
      <description>&lt;P&gt;Give this a try:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Data Cars;
input
year $  week $ Small_Size $  Mid_Size $  Large_Size $  Van $;
cards;
2018 1 10 15 23 16
2018 2 12 11 28 18
2018 3 15 19 17 11
;
run;
Data Cars; 
FORMAT YearWeek WEEKW5.;
set cars;
YearWeek=INPUT(CATS(substr(YEAR,3,2),"W",put(input(week,2.),z2.)),weekw5.);
run;

ods graphics on /
      width=10 in
      outputfmt=gif
      imagemap=on
      imagename="Cars"
      border=off;
 
PROC SGPLOT DATA = Cars;
 SERIES X = YearWeek Y = Small_Size;
 SERIES X = YearWeek Y = Mid_Size;
 SERIES X = YearWeek Y = Large_Size;
 SERIES X = YearWeek Y = Van;
/* XAXIS TYPE = DISCRETE GRID;*/
 YAXIS LABEL = 'Number of cars' GRID VALUES = (5 TO 40 BY 1);
 TITLE 'Sales by type';
 run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 15 Jun 2018 15:36:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/how-plot-2-variables-on-the-same-x-axis-controling-the-X-axis/m-p/470628#M16236</guid>
      <dc:creator>SuryaKiran</dc:creator>
      <dc:date>2018-06-15T15:36:07Z</dc:date>
    </item>
    <item>
      <title>Re: how plot 2 variables on the same x axis controling the X axis label in sgplot</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/how-plot-2-variables-on-the-same-x-axis-controling-the-X-axis/m-p/470644#M16237</link>
      <description>&lt;P&gt;SuryaKiran,&lt;/P&gt;&lt;P&gt;Thank very much!&lt;/P&gt;</description>
      <pubDate>Fri, 15 Jun 2018 16:22:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/how-plot-2-variables-on-the-same-x-axis-controling-the-X-axis/m-p/470644#M16237</guid>
      <dc:creator>Giovani</dc:creator>
      <dc:date>2018-06-15T16:22:13Z</dc:date>
    </item>
    <item>
      <title>Re: how plot 2 variables on the same x axis controling the X axis label in sgplot</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/how-plot-2-variables-on-the-same-x-axis-controling-the-X-axis/m-p/470651#M16238</link>
      <description>&lt;P&gt;If you're going to use the SGPANEL approach, another way to get rid of the gap between plots is to get rid of the axis offsets:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;colaxis offsetmin=0 offsetmax=0;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;There is the possibility of tick value collisions, but you can give it a try and see if it works for you. Also, make sure you have SPACING=0 on the PANELBY statement.&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;Thanks!&lt;/P&gt;
&lt;P&gt;Dan&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 15 Jun 2018 16:44:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/how-plot-2-variables-on-the-same-x-axis-controling-the-X-axis/m-p/470651#M16238</guid>
      <dc:creator>DanH_sas</dc:creator>
      <dc:date>2018-06-15T16:44:29Z</dc:date>
    </item>
    <item>
      <title>Re: how plot 2 variables on the same x axis controling the X axis label in sgplot</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/how-plot-2-variables-on-the-same-x-axis-controling-the-X-axis/m-p/470656#M16239</link>
      <description>&lt;P&gt;Fantastic!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank very much!&lt;/P&gt;&lt;P&gt;Working perfectlly&lt;/P&gt;</description>
      <pubDate>Fri, 15 Jun 2018 17:13:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/how-plot-2-variables-on-the-same-x-axis-controling-the-X-axis/m-p/470656#M16239</guid>
      <dc:creator>Giovani</dc:creator>
      <dc:date>2018-06-15T17:13:52Z</dc:date>
    </item>
  </channel>
</rss>

