<?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 Filling in missing date values with a count of 0 in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Filling-in-missing-date-values-with-a-count-of-0/m-p/691520#M24826</link>
    <description>&lt;P&gt;Hello!&lt;/P&gt;&lt;P&gt;I am currently trying to do a frequency count for a range of dates. I've done the frequency using the weeku6 format using this code:&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc freq data=work.test noprint;
	tables date1 / out=work.test2;
	format date1 weeku6.;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;This has given me an output of this (this is the beginning of the output):&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="procfreq.PNG" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/50651i45322DA61522D25B/image-size/medium?v=v2&amp;amp;px=400" role="button" title="procfreq.PNG" alt="procfreq.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;What I would like to do is write some code that will fill in the missing weeks in-between the range of weeks I have (this specific dataset goes from 19W43 to 20W19, but I am working with different datasets that have different start and end dates) as well as give them a count of 0. Is there a way to do this? I hope I explained this clear enough. Thank you so much for reading!!&lt;/P&gt;</description>
    <pubDate>Wed, 14 Oct 2020 13:20:43 GMT</pubDate>
    <dc:creator>mitrakos</dc:creator>
    <dc:date>2020-10-14T13:20:43Z</dc:date>
    <item>
      <title>Filling in missing date values with a count of 0</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Filling-in-missing-date-values-with-a-count-of-0/m-p/691520#M24826</link>
      <description>&lt;P&gt;Hello!&lt;/P&gt;&lt;P&gt;I am currently trying to do a frequency count for a range of dates. I've done the frequency using the weeku6 format using this code:&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc freq data=work.test noprint;
	tables date1 / out=work.test2;
	format date1 weeku6.;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;This has given me an output of this (this is the beginning of the output):&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="procfreq.PNG" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/50651i45322DA61522D25B/image-size/medium?v=v2&amp;amp;px=400" role="button" title="procfreq.PNG" alt="procfreq.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;What I would like to do is write some code that will fill in the missing weeks in-between the range of weeks I have (this specific dataset goes from 19W43 to 20W19, but I am working with different datasets that have different start and end dates) as well as give them a count of 0. Is there a way to do this? I hope I explained this clear enough. Thank you so much for reading!!&lt;/P&gt;</description>
      <pubDate>Wed, 14 Oct 2020 13:20:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Filling-in-missing-date-values-with-a-count-of-0/m-p/691520#M24826</guid>
      <dc:creator>mitrakos</dc:creator>
      <dc:date>2020-10-14T13:20:43Z</dc:date>
    </item>
    <item>
      <title>Re: Filling in missing date values with a count of 0</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Filling-in-missing-date-values-with-a-count-of-0/m-p/691528#M24827</link>
      <description>&lt;P&gt;Create some data for testing:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
input date1 yymmdd10.;
format date1 yymmdd10.;
datalines;
2020-01-01
2020-01-03
2020-01-10
2020-01-12
2020-02-05
2020-02-07
;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Then, apply your code:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc freq data=work.test noprint;
  tables date1 / out=work.test2;
  format date1 weeku6.;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Then, use a "look-ahead" to fill the gaps:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
merge
  test2
  test2 (
    firstobs=2
    keep=date1
    rename=(date1=_date1)
  )
;
output;
date1 = date1 + 7;
do while (week(date1) lt week(_date1));
  count = 0;
  percent = 0;
  output;
  date1 = date1 + 7;
end;
drop _date1;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 14 Oct 2020 13:44:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Filling-in-missing-date-values-with-a-count-of-0/m-p/691528#M24827</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-10-14T13:44:43Z</dc:date>
    </item>
    <item>
      <title>Re: Filling in missing date values with a count of 0</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Filling-in-missing-date-values-with-a-count-of-0/m-p/691582#M24828</link>
      <description>This worked beautifully thank you so much!!</description>
      <pubDate>Wed, 14 Oct 2020 16:23:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Filling-in-missing-date-values-with-a-count-of-0/m-p/691582#M24828</guid>
      <dc:creator>mitrakos</dc:creator>
      <dc:date>2020-10-14T16:23:53Z</dc:date>
    </item>
  </channel>
</rss>

