<?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: vbar xaxis values in Graphics Programming</title>
    <link>https://communities.sas.com/t5/Graphics-Programming/Sgplot-vbar-xaxis-values/m-p/562618#M18220</link>
    <description>&lt;P&gt;Thanks! This works perfectly as well. I was also able to use a macro I already had in my program to reference the start and end dates &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%let sdate=01SEP17;&lt;BR /&gt;%let edate=28FEB19;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc sgplot data=state2;&lt;BR /&gt;title 'Cases: 2017-2019';&lt;BR /&gt;format Stage $syp. eventdate monyy7.;&lt;BR /&gt;vbar eventdate / response=count group=Stage stat=sum datalabel;&lt;BR /&gt;xaxis display=(nolabel)&lt;/P&gt;&lt;P&gt;values=("&amp;amp;sdate"d to "&amp;amp;edate"d by month);&lt;BR /&gt;yaxis grid label='Cases' max=55;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;</description>
    <pubDate>Thu, 30 May 2019 16:22:32 GMT</pubDate>
    <dc:creator>mary_mcneill</dc:creator>
    <dc:date>2019-05-30T16:22:32Z</dc:date>
    <item>
      <title>Sgplot: vbar xaxis values</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Sgplot-vbar-xaxis-values/m-p/562404#M18212</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am looking for a solution to display x-axis values for missing data. Here is my current code and display. You can see that Month/Years are missing because there are not any cases during that month in the data set. I would still like to show month/year in the x-axis but there would be no bar and display 0 for that month/Year.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc sgplot data=state2;&lt;BR /&gt;title 'Cases: 2017-2019';&lt;BR /&gt;format Stage $syp. eventdate monyy7.;&lt;BR /&gt;vbar eventdate / response=count group=Stage stat=sum datalabel;&lt;BR /&gt;xaxis display=(nolabel);&lt;BR /&gt;yaxis grid label='Cases' max=55;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Missing x-axis Values: Sep2017, Jan2018, Apr2018, Jul2018, Jan2019&lt;BR /&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Graph.png" style="width: 565px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/29858i22920D496377A0FB/image-size/large?v=v2&amp;amp;px=999" role="button" title="Graph.png" alt="Graph.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 29 May 2019 20:56:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Sgplot-vbar-xaxis-values/m-p/562404#M18212</guid>
      <dc:creator>mary_mcneill</dc:creator>
      <dc:date>2019-05-29T20:56:09Z</dc:date>
    </item>
    <item>
      <title>Re: Sgplot: vbar xaxis values</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Sgplot-vbar-xaxis-values/m-p/562408#M18213</link>
      <description>&lt;P&gt;Have you tried setting the X axis to a date type? What happens then?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Edit: seems to work for me - your date variable needs to be numeric whit a date format for this to work correctly.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sgplot data=sashelp.stocks;
where year(date) ne 1991;
vbar date / response = open stat=sum group=stock;
xaxis type=time;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13026"&gt;@mary_mcneill&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am looking for a solution to display x-axis values for missing data. Here is my current code and display. You can see that Month/Years are missing because there are not any cases during that month in the data set. I would still like to show month/year in the x-axis but there would be no bar and display 0 for that month/Year.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc sgplot data=state2;&lt;BR /&gt;title 'Cases: 2017-2019';&lt;BR /&gt;format Stage $syp. eventdate monyy7.;&lt;BR /&gt;vbar eventdate / response=count group=Stage stat=sum datalabel;&lt;BR /&gt;xaxis display=(nolabel);&lt;BR /&gt;yaxis grid label='Cases' max=55;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Missing x-axis Values: Sep2017, Jan2018, Apr2018, Jul2018, Jan2019&lt;BR /&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Graph.png" style="width: 565px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/29858i22920D496377A0FB/image-size/large?v=v2&amp;amp;px=999" role="button" title="Graph.png" alt="Graph.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 29 May 2019 21:35:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Sgplot-vbar-xaxis-values/m-p/562408#M18213</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2019-05-29T21:35:02Z</dc:date>
    </item>
    <item>
      <title>Re: Sgplot: vbar xaxis values</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Sgplot-vbar-xaxis-values/m-p/562525#M18214</link>
      <description>&lt;P&gt;I tried that but I receive the following error:&amp;nbsp;WARNING: BARCHARTPARM statement has a conflict with the axis type. The plot will not be drawn&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The variable eventdate is numeric and has the date format MONYY7.&lt;/P&gt;&lt;DIV class="branch"&gt;&lt;DIV align="center"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Thu, 30 May 2019 11:31:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Sgplot-vbar-xaxis-values/m-p/562525#M18214</guid>
      <dc:creator>mary_mcneill</dc:creator>
      <dc:date>2019-05-30T11:31:37Z</dc:date>
    </item>
    <item>
      <title>Re: Sgplot: vbar xaxis values</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Sgplot-vbar-xaxis-values/m-p/562562#M18215</link>
      <description>&lt;P&gt;There might be a better more-elegant way to do this programmatically, but here's the first "brute force" solution that comes to mind. You could hard-code all the desired months along the xaxis.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here's an example, using sashelp sample data. First I remove the February data (so my data is similar to yours, with no data points during a certain month).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data my_data; set sashelp.stocks (where=(year(date) in (2005) and put(date,monname3.)^='Feb'));&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And then I generate the plot, hard-coding all the months I desire in the xaxis:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;title "Cases for 2005";&lt;BR /&gt;proc sgplot data=my_data;&lt;BR /&gt;format date monyy7.;&lt;BR /&gt;format close comma8.0;&lt;BR /&gt;vbar date / response=close stat=sum group=stock datalabel;&lt;BR /&gt;xaxis display=(nolabel)&lt;BR /&gt;&amp;nbsp; &amp;nbsp;values=('Jan2005' 'Feb2005' 'Mar2005' 'Apr2005' 'May2005' 'Jun2005'&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 'Jul2005' 'Aug2005' 'Sep2005' 'Oct2005' 'Nov2005' 'Dec2005');&lt;BR /&gt;yaxis grid label='Cases' max=200;&lt;BR /&gt;run;&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="SGPlot16.png" style="width: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/29882i18B115880A503C95/image-size/large?v=v2&amp;amp;px=999" role="button" title="SGPlot16.png" alt="SGPlot16.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 30 May 2019 13:46:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Sgplot-vbar-xaxis-values/m-p/562562#M18215</guid>
      <dc:creator>GraphGuy</dc:creator>
      <dc:date>2019-05-30T13:46:26Z</dc:date>
    </item>
    <item>
      <title>Re: Sgplot: vbar xaxis values</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Sgplot-vbar-xaxis-values/m-p/562573#M18216</link>
      <description>&lt;P&gt;Thank you so much! I had seen that option but since this report is done monthly, I was trying to see if there was another way to have them display without having to update the months/years every time the SAS program is ran, but this fixes my problem so I am going to use it!&lt;/P&gt;</description>
      <pubDate>Thu, 30 May 2019 14:15:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Sgplot-vbar-xaxis-values/m-p/562573#M18216</guid>
      <dc:creator>mary_mcneill</dc:creator>
      <dc:date>2019-05-30T14:15:37Z</dc:date>
    </item>
    <item>
      <title>Re: Sgplot: vbar xaxis values</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Sgplot-vbar-xaxis-values/m-p/562583#M18217</link>
      <description>&lt;P&gt;In the long-run, you might want to use Proc SGpanel to get the effect of a monthly bar chart "grouped" by year.&lt;/P&gt;
&lt;P&gt;Here's an example:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="http://robslink.com/SAS/ods4/it_job_openings_in_nc.htm" target="_blank"&gt;http://robslink.com/SAS/ods4/it_job_openings_in_nc.htm&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&lt;A href="http://robslink.com/SAS/ods4/it_job_openings_in_nc_info.htm" target="_blank"&gt;http://robslink.com/SAS/ods4/it_job_openings_in_nc_info.htm&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 30 May 2019 14:48:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Sgplot-vbar-xaxis-values/m-p/562583#M18217</guid>
      <dc:creator>GraphGuy</dc:creator>
      <dc:date>2019-05-30T14:48:09Z</dc:date>
    </item>
    <item>
      <title>Re: Sgplot: vbar xaxis values</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Sgplot-vbar-xaxis-values/m-p/562584#M18218</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13026"&gt;@mary_mcneill&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I tried that but I receive the following error:&amp;nbsp;WARNING: BARCHARTPARM statement has a conflict with the axis type. The plot will not be drawn&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The variable eventdate is numeric and has the date format MONYY7.&lt;/P&gt;
&lt;DIV class="branch"&gt;
&lt;DIV align="center"&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;You should post the code that generated that. Does the code I show run correctly and appear with a gap? It worked on my version of SAS as expected.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 30 May 2019 14:48:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Sgplot-vbar-xaxis-values/m-p/562584#M18218</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2019-05-30T14:48:27Z</dc:date>
    </item>
    <item>
      <title>Re: Sgplot: vbar xaxis values</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Sgplot-vbar-xaxis-values/m-p/562600#M18219</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13026"&gt;@mary_mcneill&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am looking for a solution to display x-axis values for missing data. Here is my current code and display. You can see that Month/Years are missing because there are not any cases during that month in the data set. I would still like to show month/year in the x-axis but there would be no bar and display 0 for that month/Year.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc sgplot data=state2;&lt;BR /&gt;title 'Cases: 2017-2019';&lt;BR /&gt;format Stage $syp. eventdate monyy7.;&lt;BR /&gt;vbar eventdate / response=count group=Stage stat=sum datalabel;&lt;BR /&gt;xaxis display=(nolabel);&lt;BR /&gt;yaxis grid label='Cases' max=55;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Missing x-axis Values: Sep2017, Jan2018, Apr2018, Jul2018, Jan2019&lt;BR /&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Graph.png" style="width: 565px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/29858i22920D496377A0FB/image-size/large?v=v2&amp;amp;px=999" role="button" title="Graph.png" alt="Graph.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;When your axis values are SAS date values&amp;nbsp;you can use date intervals for the&amp;nbsp;tick marks in&amp;nbsp; the VALUES= of XAXIS to accomplish what I think you want:&lt;/P&gt;
&lt;PRE&gt;proc sgplot data=sashelp.stocks;
   where year(date) in (2002 2003) and month(date) ne 6;
   vbar date / response = open stat=sum group=stock;
   xaxis values = ('01JAN2002'd to '01DEC2003'd by month);
   format date  monyy7.;
run;&lt;/PRE&gt;
&lt;P&gt;Note that I just picked a couple of months to exclude from the data to demonstrate missing data. The specific example data set has summaries on the first of the month and if your dates are not such there may be some different treatment of the ticks as midpoints but the basic principal is the same. And shorter code than listing specific values.&lt;/P&gt;</description>
      <pubDate>Thu, 30 May 2019 15:45:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Sgplot-vbar-xaxis-values/m-p/562600#M18219</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2019-05-30T15:45:45Z</dc:date>
    </item>
    <item>
      <title>Re: Sgplot: vbar xaxis values</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Sgplot-vbar-xaxis-values/m-p/562618#M18220</link>
      <description>&lt;P&gt;Thanks! This works perfectly as well. I was also able to use a macro I already had in my program to reference the start and end dates &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%let sdate=01SEP17;&lt;BR /&gt;%let edate=28FEB19;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc sgplot data=state2;&lt;BR /&gt;title 'Cases: 2017-2019';&lt;BR /&gt;format Stage $syp. eventdate monyy7.;&lt;BR /&gt;vbar eventdate / response=count group=Stage stat=sum datalabel;&lt;BR /&gt;xaxis display=(nolabel)&lt;/P&gt;&lt;P&gt;values=("&amp;amp;sdate"d to "&amp;amp;edate"d by month);&lt;BR /&gt;yaxis grid label='Cases' max=55;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;</description>
      <pubDate>Thu, 30 May 2019 16:22:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Sgplot-vbar-xaxis-values/m-p/562618#M18220</guid>
      <dc:creator>mary_mcneill</dc:creator>
      <dc:date>2019-05-30T16:22:32Z</dc:date>
    </item>
    <item>
      <title>Re: Sgplot: vbar xaxis values</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Sgplot-vbar-xaxis-values/m-p/562619#M18221</link>
      <description>&lt;P&gt;Running the below code with the xaxis type=time did not produce any graphs. I verified in SAS proc contents that event date was in fact numeric with a date format and it was. Perhaps I was missing something?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc sgplot data=state2;&lt;BR /&gt;title 'Cases: 2017-2019';&lt;BR /&gt;format Stage $syp. eventdate monyy7.;&lt;BR /&gt;vbar eventdate / response=count group=Stage stat=sum datalabel;&lt;BR /&gt;xaxis type=time;&lt;BR /&gt;yaxis grid label='Cases' max=55;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;</description>
      <pubDate>Thu, 30 May 2019 16:27:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Sgplot-vbar-xaxis-values/m-p/562619#M18221</guid>
      <dc:creator>mary_mcneill</dc:creator>
      <dc:date>2019-05-30T16:27:46Z</dc:date>
    </item>
  </channel>
</rss>

