<?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: Creating a frequency output for a range of dates in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Creating-a-frequency-output-for-a-range-of-dates/m-p/689741#M79644</link>
    <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/351308"&gt;@mitrakos&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hello!&lt;/P&gt;
&lt;P&gt;I'm working with a dataset and I am trying to compile a frequency output of some sort for a range of dates. To expand, I have a list of dates and I want to run code that looks at the list of dates and outputs how often dates fall within a weekly timeframe.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;10DEC2019&lt;/P&gt;
&lt;P&gt;11DEC2019&lt;/P&gt;
&lt;P&gt;12DEC2019&lt;/P&gt;
&lt;P&gt;13DEC2019&lt;/P&gt;
&lt;P&gt;14DEC2019&lt;/P&gt;
&lt;P&gt;....&lt;/P&gt;
&lt;P&gt;This goes all the way until May, with not all dates between December and May included&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
	set have;
	WHERE date1 between '10DEC2019'd and '17DEC2019'd;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Currently this is what I am using to find frequency of dates in week intervals, by counting the results of the new dataset. However as you can imagine this is a slow process. I was wondering if there is a more automated and more effective way of doing this. Thank you!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;You need to explain more about what you mean by " with not all dates between December and May included". Does that mean you have data in the interval that you need to exclude? Then you need to provide the rules of which to exclude.&lt;/P&gt;
&lt;P&gt;Or does it mean that you just don't happen to have any data on certain dates? Likely nothing needs to be done.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You might also need to describe what you are defining as "week". SAS has three different standard definitions of "week" depending on how you define the first day of the week and involving year-end-boundaries.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here is some example code showing dates and the week format (or similar to the WEEK functions).&lt;/P&gt;
&lt;PRE&gt;data _null_;
   file print ;
   do date='25DEC2019'd to '07JAN2021'd;
   put date=date9. " WeekU: " date weeku. " WeekV: " date weekv. " WeekW: " date weekw.;
   end;
run;&lt;/PRE&gt;
&lt;P&gt;If you use a 5 or 6 wide value, such as Weeku7 the result will have a result like:&amp;nbsp; 20W05 to indicate the 5th week of 2020.&lt;/P&gt;
&lt;P&gt;You can also make custom formats that might work. Why the discussion of formats? You can create groups that would be recognized by procs like Freq to create a group, or for graphing.&lt;/P&gt;
&lt;DIV class="xis-refDictEntry"&gt;
&lt;DIV class="xis-details"&gt;
&lt;DIV id="n1og7vl9nrcw9un18etoat3nzv4m" class="xis-topicContent"&gt;
&lt;DIV id="n1v50530f4m8g3n13s58j27hujw7" class="xis-table"&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;</description>
    <pubDate>Wed, 07 Oct 2020 21:24:42 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2020-10-07T21:24:42Z</dc:date>
    <item>
      <title>Creating a frequency output for a range of dates</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Creating-a-frequency-output-for-a-range-of-dates/m-p/689718#M79642</link>
      <description>&lt;P&gt;Hello!&lt;/P&gt;&lt;P&gt;I'm working with a dataset and I am trying to compile a frequency output of some sort for a range of dates. To expand, I have a list of dates and I want to run code that looks at the list of dates and outputs how often dates fall within a weekly timeframe.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;10DEC2019&lt;/P&gt;&lt;P&gt;11DEC2019&lt;/P&gt;&lt;P&gt;12DEC2019&lt;/P&gt;&lt;P&gt;13DEC2019&lt;/P&gt;&lt;P&gt;14DEC2019&lt;/P&gt;&lt;P&gt;....&lt;/P&gt;&lt;P&gt;This goes all the way until May, with not all dates between December and May included&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
	set have;
	WHERE date1 between '10DEC2019'd and '17DEC2019'd;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Currently this is what I am using to find frequency of dates in week intervals, by counting the results of the new dataset. However as you can imagine this is a slow process. I was wondering if there is a more automated and more effective way of doing this. Thank you!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 07 Oct 2020 20:17:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Creating-a-frequency-output-for-a-range-of-dates/m-p/689718#M79642</guid>
      <dc:creator>mitrakos</dc:creator>
      <dc:date>2020-10-07T20:17:32Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a frequency output for a range of dates</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Creating-a-frequency-output-for-a-range-of-dates/m-p/689720#M79643</link>
      <description>&lt;P&gt;Run PROC FREQ on your variable, and use one of the WEEK formats. PROC FREQ will use the formatted value for the counts.&lt;/P&gt;</description>
      <pubDate>Wed, 07 Oct 2020 20:23:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Creating-a-frequency-output-for-a-range-of-dates/m-p/689720#M79643</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-10-07T20:23:59Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a frequency output for a range of dates</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Creating-a-frequency-output-for-a-range-of-dates/m-p/689741#M79644</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/351308"&gt;@mitrakos&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hello!&lt;/P&gt;
&lt;P&gt;I'm working with a dataset and I am trying to compile a frequency output of some sort for a range of dates. To expand, I have a list of dates and I want to run code that looks at the list of dates and outputs how often dates fall within a weekly timeframe.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;10DEC2019&lt;/P&gt;
&lt;P&gt;11DEC2019&lt;/P&gt;
&lt;P&gt;12DEC2019&lt;/P&gt;
&lt;P&gt;13DEC2019&lt;/P&gt;
&lt;P&gt;14DEC2019&lt;/P&gt;
&lt;P&gt;....&lt;/P&gt;
&lt;P&gt;This goes all the way until May, with not all dates between December and May included&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
	set have;
	WHERE date1 between '10DEC2019'd and '17DEC2019'd;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Currently this is what I am using to find frequency of dates in week intervals, by counting the results of the new dataset. However as you can imagine this is a slow process. I was wondering if there is a more automated and more effective way of doing this. Thank you!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;You need to explain more about what you mean by " with not all dates between December and May included". Does that mean you have data in the interval that you need to exclude? Then you need to provide the rules of which to exclude.&lt;/P&gt;
&lt;P&gt;Or does it mean that you just don't happen to have any data on certain dates? Likely nothing needs to be done.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You might also need to describe what you are defining as "week". SAS has three different standard definitions of "week" depending on how you define the first day of the week and involving year-end-boundaries.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here is some example code showing dates and the week format (or similar to the WEEK functions).&lt;/P&gt;
&lt;PRE&gt;data _null_;
   file print ;
   do date='25DEC2019'd to '07JAN2021'd;
   put date=date9. " WeekU: " date weeku. " WeekV: " date weekv. " WeekW: " date weekw.;
   end;
run;&lt;/PRE&gt;
&lt;P&gt;If you use a 5 or 6 wide value, such as Weeku7 the result will have a result like:&amp;nbsp; 20W05 to indicate the 5th week of 2020.&lt;/P&gt;
&lt;P&gt;You can also make custom formats that might work. Why the discussion of formats? You can create groups that would be recognized by procs like Freq to create a group, or for graphing.&lt;/P&gt;
&lt;DIV class="xis-refDictEntry"&gt;
&lt;DIV class="xis-details"&gt;
&lt;DIV id="n1og7vl9nrcw9un18etoat3nzv4m" class="xis-topicContent"&gt;
&lt;DIV id="n1v50530f4m8g3n13s58j27hujw7" class="xis-table"&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;</description>
      <pubDate>Wed, 07 Oct 2020 21:24:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Creating-a-frequency-output-for-a-range-of-dates/m-p/689741#M79644</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2020-10-07T21:24:42Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a frequency output for a range of dates</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Creating-a-frequency-output-for-a-range-of-dates/m-p/689795#M79647</link>
      <description>&lt;P&gt;Just apply a week format to the data.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc freq data=have noprint;
table date1 / out=want;
format date1 weeku3.;
run;

&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;A href="https://gist.github.com/statgeek/0cae5568752959b035516d6ac07a20fb" target="_blank"&gt;https://gist.github.com/statgeek/0cae5568752959b035516d6ac07a20fb&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/351308"&gt;@mitrakos&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hello!&lt;/P&gt;
&lt;P&gt;I'm working with a dataset and I am trying to compile a frequency output of some sort for a range of dates. To expand, I have a list of dates and I want to run code that looks at the list of dates and outputs how often dates fall within a weekly timeframe.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;10DEC2019&lt;/P&gt;
&lt;P&gt;11DEC2019&lt;/P&gt;
&lt;P&gt;12DEC2019&lt;/P&gt;
&lt;P&gt;13DEC2019&lt;/P&gt;
&lt;P&gt;14DEC2019&lt;/P&gt;
&lt;P&gt;....&lt;/P&gt;
&lt;P&gt;This goes all the way until May, with not all dates between December and May included&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
	set have;
	WHERE date1 between '10DEC2019'd and '17DEC2019'd;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Currently this is what I am using to find frequency of dates in week intervals, by counting the results of the new dataset. However as you can imagine this is a slow process. I was wondering if there is a more automated and more effective way of doing this. Thank you!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 08 Oct 2020 00:53:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Creating-a-frequency-output-for-a-range-of-dates/m-p/689795#M79647</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2020-10-08T00:53:20Z</dc:date>
    </item>
  </channel>
</rss>

