<?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: 2 level X Axis in SGPlot? in Graphics Programming</title>
    <link>https://communities.sas.com/t5/Graphics-Programming/2-level-X-Axis-in-SGPlot/m-p/180347#M6637</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Here are some ideas for EPI graphs in this &lt;A href="http://http//blogs.sas.com/content/graphicallyspeaking/?s=epi"&gt;blog article&lt;/A&gt; that you may find useful..&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 13 Jan 2015 20:04:11 GMT</pubDate>
    <dc:creator>Jay54</dc:creator>
    <dc:date>2015-01-13T20:04:11Z</dc:date>
    <item>
      <title>2 level X Axis in SGPlot?</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/2-level-X-Axis-in-SGPlot/m-p/180343#M6633</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;BR /&gt;I have created a simple vbar chart from data like the attached (I can't figure out how to paste into this browser).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;And I have used sgplot to make a simple bar chart, with the colors of the bars different for each week depending on the "code" column.&amp;nbsp; I also got the weeks to appear in the data order!&amp;nbsp; This is nice, since the data is epi data, and they do things by year and week.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Attached is a sample of the output.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The code was this, roughly.......&lt;/P&gt;&lt;P&gt;proc sgplot data= d300 dattrmap=attrmap; &lt;/P&gt;&lt;P&gt;vbar week /response=percent group=code attrid=code nooutline; &lt;/P&gt;&lt;P&gt;xaxis label='Epi Week' type=discrete discreteorder=data; &lt;/P&gt;&lt;P&gt;keylegend&amp;nbsp; / title='';&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So right now it all looks like I want.&amp;nbsp; However, I see a need in the future to have both the week and the year as the labels on the xaxis.&amp;nbsp; So, in other words, the week would still be displayed as it is now, with year as a second level label under the weeks (year only appearing once, centered under the weeks it covers).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have not been able to find an example of how to do this.&amp;nbsp; Is it possible?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Nicole&lt;/P&gt;&lt;BR /&gt;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/10648iB20458C5A1B46F9B/image-size/large?v=1.0&amp;amp;px=600" border="0" alt="sampleoutput.png" title="sampleoutput.png" /&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 13 Jan 2015 17:06:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/2-level-X-Axis-in-SGPlot/m-p/180343#M6633</guid>
      <dc:creator>NWV</dc:creator>
      <dc:date>2015-01-13T17:06:14Z</dc:date>
    </item>
    <item>
      <title>Re: 2 level X Axis in SGPlot?</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/2-level-X-Axis-in-SGPlot/m-p/180344#M6634</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;In the next release of SAS, we will have support for interval bar charts. This means you'll be able to plot bar charts along a continuous number line, including time lines. Our time axis already has support for the two-level labeling you describe, so the code will be very simple:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sgplot data=sashelp.air;&lt;/P&gt;&lt;P&gt;where date &amp;gt;= '01jan1959'd;&lt;/P&gt;&lt;P&gt;xaxis type=time;&lt;/P&gt;&lt;P&gt;vbar date / response=air;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG alt="IntervalBar.png" class="jive-image-thumbnail jive-image" src="https://communities.sas.com/legacyfs/online/8694_IntervalBar.png" width="450" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 13 Jan 2015 17:53:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/2-level-X-Axis-in-SGPlot/m-p/180344#M6634</guid>
      <dc:creator>DanH_sas</dc:creator>
      <dc:date>2015-01-13T17:53:22Z</dc:date>
    </item>
    <item>
      <title>Re: 2 level X Axis in SGPlot?</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/2-level-X-Axis-in-SGPlot/m-p/180345#M6635</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;That does look like what I want, except I don't have dates, I have weeks.&amp;nbsp; And my x axis is not a time axis, so it sounds like I will have to wait until the next version of SAS?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 13 Jan 2015 18:17:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/2-level-X-Axis-in-SGPlot/m-p/180345#M6635</guid>
      <dc:creator>NWV</dc:creator>
      <dc:date>2015-01-13T18:17:31Z</dc:date>
    </item>
    <item>
      <title>Re: 2 level X Axis in SGPlot?</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/2-level-X-Axis-in-SGPlot/m-p/180346#M6636</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The interval bar chart will be in the next release; but, the only axis with two-level support is the time axis. If you are willing to use GTL, you might be able to accomplish what you want using block plots in conjunction with a bar chart. Basically, you would turn off the X-axis and use two axis-aligned block plots. Try the following example and see if it works for you:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc template;&lt;/P&gt;&lt;P&gt;define statgraph bar_sample;&lt;/P&gt;&lt;P&gt;begingraph;&lt;/P&gt;&lt;P&gt;&amp;nbsp; entrytitle "Regional Sales Figures";&lt;/P&gt;&lt;P&gt;&amp;nbsp; layout lattice / rowweights=preferred;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; layout overlay / xaxisopts=(display=(line ticks));&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; barchartparm x=year_month y=actual / group=region name="sales";&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; endlayout;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; blockplot x=year_month block=month / valuehalign=start display=(label values)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; valuefitpolicy=shrink;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; blockplot x=year_month block=year / valuehalign=start display=(label values)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; valuefitpolicy=shrink;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; sidebar / align=bottom spacefill=false;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; discretelegend "sales";&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; endsidebar;&lt;/P&gt;&lt;P&gt;&amp;nbsp; endlayout;&lt;/P&gt;&lt;P&gt;endgraph;&lt;/P&gt;&lt;P&gt;end;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;/* Pre-summarize the data so that the block plots will render correctly */&lt;/P&gt;&lt;P&gt;proc summary data=sashelp.prdsale nway;&lt;/P&gt;&lt;P&gt;class year month region;&lt;/P&gt;&lt;P&gt;var actual;&lt;/P&gt;&lt;P&gt;output out=temp sum=;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;/* Build the X-axis variable to create unique category values */&lt;/P&gt;&lt;P&gt;data temp2;&lt;/P&gt;&lt;P&gt;set temp;&lt;/P&gt;&lt;P&gt;year_month = year||month;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sgrender data=temp2 template=bar_sample; run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG alt="two_level.png" class="jive-image-thumbnail jive-image" src="https://communities.sas.com/legacyfs/online/8695_two_level.png" width="450" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 13 Jan 2015 19:20:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/2-level-X-Axis-in-SGPlot/m-p/180346#M6636</guid>
      <dc:creator>DanH_sas</dc:creator>
      <dc:date>2015-01-13T19:20:55Z</dc:date>
    </item>
    <item>
      <title>Re: 2 level X Axis in SGPlot?</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/2-level-X-Axis-in-SGPlot/m-p/180347#M6637</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Here are some ideas for EPI graphs in this &lt;A href="http://http//blogs.sas.com/content/graphicallyspeaking/?s=epi"&gt;blog article&lt;/A&gt; that you may find useful..&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 13 Jan 2015 20:04:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/2-level-X-Axis-in-SGPlot/m-p/180347#M6637</guid>
      <dc:creator>Jay54</dc:creator>
      <dc:date>2015-01-13T20:04:11Z</dc:date>
    </item>
    <item>
      <title>Re: 2 level X Axis in SGPlot?</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/2-level-X-Axis-in-SGPlot/m-p/180348#M6638</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Sanjay, thank you for the response.&amp;nbsp; The link did not work for me--did you mean this one?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A class="jive-link-external-small" href="http://blogs.sas.com/content/graphicallyspeaking/2014/08/09/epidemic-curve-graph/"&gt;http://blogs.sas.com/content/graphicallyspeaking/2014/08/09/epidemic-curve-graph/&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;I have referenced many of your articles and your book (graphics by example) as I have learned sgplot.&amp;nbsp; Thank you for breaking things down for the average user.&amp;nbsp; I learned to apply the attribute map from that blog article.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I did read that article on epi curves, although I did not need to go to the full extent of using the data labels to label the x axis--we had a variable for epiweek in the data, and I just made sure there was an observation for each week in the data, so there are no gaps.&amp;nbsp; Then ordering the xaxis by the data was enough.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;However, to go the next step, once the epiweeks start "wrapping," (i.e. we have epi week 30 for both 2014 and 2015 in the data), I foresee a need to be able to put the year under the week in the xaxis, sort of as a second level category.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I will give the GTL example above from Dan a try at some point, although I am trying to keep the code as simple as possible, because I am trying to convince some folks who love excel that SAS can do it just as well, and that it is not too difficult.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 14 Jan 2015 13:41:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/2-level-X-Axis-in-SGPlot/m-p/180348#M6638</guid>
      <dc:creator>NWV</dc:creator>
      <dc:date>2015-01-14T13:41:41Z</dc:date>
    </item>
  </channel>
</rss>

