<?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: Display every other date label in SGPlot without changing the number of bars in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Display-every-other-date-label-in-SGPlot-without-changing-the/m-p/714451#M220572</link>
    <description>&lt;P&gt;Try adding option FITPOLICY=THIN or FITPOLICY=STAGGERTHIN to your XAXIS statement.&lt;/P&gt;</description>
    <pubDate>Tue, 26 Jan 2021 23:06:55 GMT</pubDate>
    <dc:creator>PGStats</dc:creator>
    <dc:date>2021-01-26T23:06:55Z</dc:date>
    <item>
      <title>Display every other date label in SGPlot without changing the number of bars</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Display-every-other-date-label-in-SGPlot-without-changing-the/m-p/714408#M220554</link>
      <description>&lt;P&gt;I have been graphing the number of Product A manufactured and the percent prevalence of defects by week. The data begins in early June and by this point the x axis is getting awfully congested. I would like to change the labeling to show the start date of every other week. I am not sure how much longer these graphs will be needed, so hard coding the tick marks seems like a bit of a pain. I tried including values=(date1 to date2 by 14), however, this combines the two weeks of data into one bar and I need all of the bars. I then tried using mod(date, 2)=0 to select every other date, but can't figure out how to only apply this to the labels. I also tried using formats, but since the graph has data from both 2020 to 2021, it creates a mess. Below is how I created the week variables, my original SGPlot code for the original graph I have, and for the one which creates the combined bars. I have attached a pdf of the graph outputs and a tab delimited file with some sample observations for one of the warehouses.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/*Create week variables*/
data demo; set foo;
	week1=week(date,"u");
	nweek=week1-22;
run;

data demo2; set demo;
	if first.nweek then displayweek=date; /*show first day of each week*/
		displayweek+0;
	if last.nweek then graphweek=displayweek;
run;

/*Graphs*/
title "Original";
proc sgplot data=demo2; 
xaxis label="Week Beginning" labelattrs=(size=12pt weight=bold)
	valueattrs=(size=12pt);
yaxis min=0 label="Count" INTEGER labelattrs=(size=12pt weight=bold)
	valueattrs=(size=13pt) fitpolicy=thin offsetmin=0;
y2axis min=0 label="%" labelattrs=(size=12pt weight=bold)
	valueattrs=(size=13pt) fitpolicy=thin offsetmin=0;

vbar graphweek/response=count legendlabel="Number";
vline graphweek/response=pct y2axis legendlabel="Percent"
	lineattrs=(thickness=2)
	markers MARKERATTRS=(symbol=TriangleFilled);

run;

title "Fix Attempt";
proc sgplot data=demo2; 
xaxis label="Week Beginning" interval=auto  
	values=('07jun20'd to &amp;amp;lastday by 14) valuesformat=date.
	labelattrs=(size=12pt weight=bold) valueattrs=(size=12pt);
yaxis min=0 label="Count" INTEGER labelattrs=(size=12pt weight=bold)
	valueattrs=(size=13pt) fitpolicy=thin offsetmin=0;
y2axis min=0 label="Percent" labelattrs=(size=12pt weight=bold)
	valueattrs=(size=13pt) fitpolicy=thin offsetmin=0;

vbar graphweek/response=count legendlabel="Number";
vline graphweek/response=pct y2axis legendlabel="Percent"
	lineattrs=(thickness=2)
	markers MARKERATTRS=(symbol=TriangleFilled);

run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 26 Jan 2021 20:31:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Display-every-other-date-label-in-SGPlot-without-changing-the/m-p/714408#M220554</guid>
      <dc:creator>mae_day</dc:creator>
      <dc:date>2021-01-26T20:31:29Z</dc:date>
    </item>
    <item>
      <title>Re: Display every other date label in SGPlot without changing the number of bars</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Display-every-other-date-label-in-SGPlot-without-changing-the/m-p/714416#M220559</link>
      <description>&lt;P&gt;With a large and apparently growing number of categories I would suggest moving from VBAR to NEEDLE plot.&lt;/P&gt;
&lt;P&gt;Two required parameters x=graphweek and y=count and set a needle width large enough to look "bar" like with the LINEATTRS=( Thickness= n ) option. You even get to specify a unit type like CM MM or IN for the thickness. 5mm&amp;nbsp; would make the "bars" 5mm wide.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Then your xaxis can use date ranges like Values = ('01JAN2021'd to '01OCT2021'd by month) to create one tick mark per month. If you end up with long enough series then you can use "by quarter" or even "by year".&lt;/P&gt;</description>
      <pubDate>Tue, 26 Jan 2021 20:59:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Display-every-other-date-label-in-SGPlot-without-changing-the/m-p/714416#M220559</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2021-01-26T20:59:58Z</dc:date>
    </item>
    <item>
      <title>Re: Display every other date label in SGPlot without changing the number of bars</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Display-every-other-date-label-in-SGPlot-without-changing-the/m-p/714451#M220572</link>
      <description>&lt;P&gt;Try adding option FITPOLICY=THIN or FITPOLICY=STAGGERTHIN to your XAXIS statement.&lt;/P&gt;</description>
      <pubDate>Tue, 26 Jan 2021 23:06:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Display-every-other-date-label-in-SGPlot-without-changing-the/m-p/714451#M220572</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2021-01-26T23:06:55Z</dc:date>
    </item>
    <item>
      <title>Re: Display every other date label in SGPlot without changing the number of bars</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Display-every-other-date-label-in-SGPlot-without-changing-the/m-p/716209#M221302</link>
      <description>&lt;P&gt;Apologies for the delayed response. This was so close to working! I had to adjust the weeks because any week with less than 7 days, caused an overlapping bar. Unfortunately it's highly likely that I will need to send out this graph at various points during the week (e.g. not always at the end of a week), so the last week displayed is off (see attached picture). I tried further adjusting the bar widths, but it didn't help.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any suggestions?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 02 Feb 2021 20:22:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Display-every-other-date-label-in-SGPlot-without-changing-the/m-p/716209#M221302</guid>
      <dc:creator>mae_day</dc:creator>
      <dc:date>2021-02-02T20:22:51Z</dc:date>
    </item>
  </channel>
</rss>

