<?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: Add zero frequency with VLINE in Graphics Programming</title>
    <link>https://communities.sas.com/t5/Graphics-Programming/Add-zero-frequency-with-VLINE/m-p/621497#M19388</link>
    <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/15410"&gt;@data_null__&lt;/a&gt;&amp;nbsp;has provided an excellent solution. I am annotating my original code to show how I modified it to add the zero frequencies and showing the resulting plot. The key is the &lt;STRONG&gt;completetypes&lt;/STRONG&gt; option in proc summary, which adds zero frequencies automatically.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;&lt;FONT color="#FF0000"&gt;proc summary data=events nway completetypes;
 class month year;
 output out=_4plot;
run;&lt;/FONT&gt;

proc sgplot data=&lt;FONT color="#FF0000"&gt;_4plot&lt;/FONT&gt;;
 vline month / group=year markers &lt;FONT color="#FF0000"&gt;response=_freq_&lt;/FONT&gt;;
 &lt;FONT color="#FF0000"&gt;yaxis label="Frequency";&lt;/FONT&gt;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="image.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/35786i00EA5E1DC78BE08C/image-size/medium?v=v2&amp;amp;px=400" role="button" title="image.png" alt="image.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
    <pubDate>Fri, 31 Jan 2020 17:21:12 GMT</pubDate>
    <dc:creator>aknez</dc:creator>
    <dc:date>2020-01-31T17:21:12Z</dc:date>
    <item>
      <title>Add zero frequency with VLINE</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Add-zero-frequency-with-VLINE/m-p/621326#M19381</link>
      <description>&lt;P&gt;I have a data set of events that occur over time. Each observation is an event with a date and I create two variables from the date: &lt;STRONG&gt;month&lt;/STRONG&gt; and &lt;STRONG&gt;year&lt;/STRONG&gt;. I use VLINE to plot the frequency of events that occur each month over several years.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I love how easy this is to implement in SGPLOT with VLINE but I would like to add one thing: in Dec 2018 there were no events (see blue line). Is there a way to have VLINE plot a zero for this month?&lt;/P&gt;&lt;P&gt;&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=classes;
 vline month / group=year markers;
run; &lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="image.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/35765iD48B6E934E0CAA62/image-size/medium?v=v2&amp;amp;px=400" role="button" title="image.png" alt="image.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 30 Jan 2020 22:14:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Add-zero-frequency-with-VLINE/m-p/621326#M19381</guid>
      <dc:creator>aknez</dc:creator>
      <dc:date>2020-01-30T22:14:55Z</dc:date>
    </item>
    <item>
      <title>Re: Add zero frequency with VLINE</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Add-zero-frequency-with-VLINE/m-p/621338#M19382</link>
      <description>&lt;P&gt;At the urging of&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/138205"&gt;@novinosrin&lt;/a&gt; I am adding notes.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;My first thought and was to use the FREQ= option but I found that values with 0 are discarded.&amp;nbsp; So I ended with the trick of plotting the sum.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The first step is something from nothing&amp;nbsp; COMPLETETYPES.&amp;nbsp; This creates obs with zero freq for AGE=16 sex=F.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Plotting the SUM of _FREQ_ is straight forward but you don't get a nice Y axis label but that can be fixed.&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;yaxis label='Frequency' values=(0 to 3);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;ODS TRACE and ODS OUTPUT are not really needed but I want to see the data that SPLOT used.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc summary data=sashelp.class nway missing completetypes;
   class age sex;
   output out=_4plot;
   run;
proc print;
   run; 
   
ods trace on;
ods output SGPlot=SGPlot;
proc sgplot data=_4plot;
   vline age / group=sex response=_freq_ stat=sum markers;
   run;
ods trace off;
proc print;
   run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Capture.PNG" style="width: 525px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/35772iA92FE8909827DD76/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, 31 Jan 2020 14:09:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Add-zero-frequency-with-VLINE/m-p/621338#M19382</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2020-01-31T14:09:01Z</dc:date>
    </item>
    <item>
      <title>Re: Add zero frequency with VLINE</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Add-zero-frequency-with-VLINE/m-p/621427#M19385</link>
      <description>&lt;P&gt;Guru&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/15410"&gt;@data_null__&lt;/a&gt;&amp;nbsp; Needless to say as usual yours has to be great. May i request you to add a couple of comments that addressed the solution appropriately so that people can diligently take notes? Only when you have a moment to spare. I understand!&lt;/P&gt;</description>
      <pubDate>Fri, 31 Jan 2020 13:38:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Add-zero-frequency-with-VLINE/m-p/621427#M19385</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2020-01-31T13:38:18Z</dc:date>
    </item>
    <item>
      <title>Re: Add zero frequency with VLINE</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Add-zero-frequency-with-VLINE/m-p/621497#M19388</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/15410"&gt;@data_null__&lt;/a&gt;&amp;nbsp;has provided an excellent solution. I am annotating my original code to show how I modified it to add the zero frequencies and showing the resulting plot. The key is the &lt;STRONG&gt;completetypes&lt;/STRONG&gt; option in proc summary, which adds zero frequencies automatically.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;&lt;FONT color="#FF0000"&gt;proc summary data=events nway completetypes;
 class month year;
 output out=_4plot;
run;&lt;/FONT&gt;

proc sgplot data=&lt;FONT color="#FF0000"&gt;_4plot&lt;/FONT&gt;;
 vline month / group=year markers &lt;FONT color="#FF0000"&gt;response=_freq_&lt;/FONT&gt;;
 &lt;FONT color="#FF0000"&gt;yaxis label="Frequency";&lt;/FONT&gt;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="image.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/35786i00EA5E1DC78BE08C/image-size/medium?v=v2&amp;amp;px=400" role="button" title="image.png" alt="image.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 31 Jan 2020 17:21:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Add-zero-frequency-with-VLINE/m-p/621497#M19388</guid>
      <dc:creator>aknez</dc:creator>
      <dc:date>2020-01-31T17:21:12Z</dc:date>
    </item>
  </channel>
</rss>

