<?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: Count for a specific date range in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Count-for-a-specific-date-range/m-p/511185#M2128</link>
    <description>&lt;P&gt;Interesting, I've just noticed that&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13871"&gt;@DBailey&lt;/a&gt;&amp;nbsp;had posted another reply. A quick comparison of the results (for made-up&amp;nbsp;input data) has revealed &lt;EM&gt;that they differ! &lt;/EM&gt;I leave it to you,&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/228641"&gt;@aperansi&lt;/a&gt;, to decide which solution is correct for your purposes. (I'd use your example, the invoice for August 2018, to find out.)&lt;/P&gt;</description>
    <pubDate>Wed, 07 Nov 2018 20:29:59 GMT</pubDate>
    <dc:creator>FreelanceReinh</dc:creator>
    <dc:date>2018-11-07T20:29:59Z</dc:date>
    <item>
      <title>Count for a specific date range</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Count-for-a-specific-date-range/m-p/510877#M2043</link>
      <description>&lt;P&gt;&lt;SPAN&gt;I have a dataset that I created that pulls in data over a 13 month period. I am pulling a list of unique keys and dates, and I am getting a count of the keys within a given day.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;The issue im running into&amp;nbsp;i that I need the count to express the count of api_calls that happen in a month and go from the last Saturday&amp;nbsp;of the previous month, to the last Friday of the current month. The current month should be the month where the count is recorded.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;For example: I have an invoice for August. The start date of that invoice would be July 28, 2018 (Last Saturday of the Month) to August 31, 2018 (Last Friday of the current month). The count for August should reflect the above period. And all other months should be consistent with this as well.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Could someone please help me figure out how to code this into my program?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 27 Nov 2018 20:09:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Count-for-a-specific-date-range/m-p/510877#M2043</guid>
      <dc:creator>aperansi</dc:creator>
      <dc:date>2018-11-27T20:09:27Z</dc:date>
    </item>
    <item>
      <title>Re: Count for a specific date range</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Count-for-a-specific-date-range/m-p/510916#M2048</link>
      <description>&lt;P&gt;A possible start is to express a date in a Month-day-week format&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;that has month&amp;nbsp;( 1 - 12 ), week (1 - 4), day (1 - 7)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Then assign variables&amp;nbsp;month, week, day based on the formatted dates&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;group by month, week, day&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;(a) count whole month, (b) count last friday&amp;nbsp;to the end of the month, (c) count last saturday&amp;nbsp;of previous month to the end of that month.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;final count = (a) - (b) + (c)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 06 Nov 2018 22:18:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Count-for-a-specific-date-range/m-p/510916#M2048</guid>
      <dc:creator>pink_poodle</dc:creator>
      <dc:date>2018-11-06T22:18:11Z</dc:date>
    </item>
    <item>
      <title>Re: Count for a specific date range</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Count-for-a-specific-date-range/m-p/510926#M2050</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/228641"&gt;@aperansi&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can adapt the &lt;A href="https://communities.sas.com/t5/SAS-Programming/Getting-a-count-for-a-specific-date-range/m-p/506882#M135918" target="_blank"&gt;solution in the earlier thread&lt;/A&gt; to the new period definition. For example, the "invoice month" for a given &lt;FONT face="courier new,courier"&gt;api_date&lt;/FONT&gt; (e.g. &lt;FONT face="courier new,courier"&gt;'2018-08'&lt;/FONT&gt; for &lt;FONT face="courier new,courier"&gt;api_date='30JUL2018'd&lt;/FONT&gt;) can be written as&lt;/P&gt;
&lt;PRE&gt;put(intnx('month',api_date,api_date&amp;gt;nwkdom(5,6,month(api_date),year(api_date))),yymmd7.)&lt;/PRE&gt;</description>
      <pubDate>Wed, 07 Nov 2018 00:20:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Count-for-a-specific-date-range/m-p/510926#M2050</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2018-11-07T00:20:43Z</dc:date>
    </item>
    <item>
      <title>Re: Count for a specific date range</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Count-for-a-specific-date-range/m-p/511071#M2102</link>
      <description>&lt;P&gt;Im having trouble working through this in my head. Can you help me understand this a little more?&lt;/P&gt;</description>
      <pubDate>Wed, 07 Nov 2018 16:16:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Count-for-a-specific-date-range/m-p/511071#M2102</guid>
      <dc:creator>aperansi</dc:creator>
      <dc:date>2018-11-07T16:16:36Z</dc:date>
    </item>
    <item>
      <title>Re: Count for a specific date range</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Count-for-a-specific-date-range/m-p/511105#M2109</link>
      <description>&lt;P&gt;Sure. Let's analyze the expression&amp;nbsp;from the inside outwards:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;The &lt;A href="https://documentation.sas.com/?cdcId=pgmsascdc&amp;amp;cdcVersion=9.4_3.4&amp;amp;docsetId=lefunctionsref&amp;amp;docsetTarget=n0bn6385z4pweqn1qrpmklqtln99.htm&amp;amp;locale=en" target="_blank"&gt;MONTH&lt;/A&gt; and &lt;A href="https://documentation.sas.com/?cdcId=pgmsascdc&amp;amp;cdcVersion=9.4_3.4&amp;amp;docsetId=lefunctionsref&amp;amp;docsetTarget=p13eycdrmfb0l8n1492z3wocpt3s.htm&amp;amp;locale=en" target="_blank"&gt;YEAR&lt;/A&gt; functions are applied to the SAS date value in &lt;FONT face="courier new,courier"&gt;api_date&lt;/FONT&gt; to obtain month and year of the respective date. These are the third and fourth argument of function &lt;A href="https://documentation.sas.com/?cdcId=pgmsascdc&amp;amp;cdcVersion=9.4_3.4&amp;amp;docsetId=lefunctionsref&amp;amp;docsetTarget=p1kdveu0ry8ltxn1m3um2ntxs7d5.htm&amp;amp;locale=en" target="_blank"&gt;NWKDOM&lt;/A&gt;.&lt;/LI&gt;
&lt;LI&gt;The first two arguments of NWKDOM, 5 and 6, stand for the fifth (or last) Friday (=sixth day of the week in SAS) of the month specified in the other two arguments. So,&amp;nbsp;&lt;FONT face="courier new,courier"&gt;nwkdom(5,6,month(api_date),year(api_date))&lt;/FONT&gt; is the SAS date value of the last Friday&amp;nbsp;of the month &lt;FONT face="courier new,courier"&gt;api_date&lt;/FONT&gt; falls into. (As described in the documentation of NWKDOM, the 5 in the first argument works even in cases where the last Friday is only the &lt;EM&gt;fourth&lt;/EM&gt; Friday of the month.)&lt;/LI&gt;
&lt;LI&gt;The inequality &lt;FONT face="courier new,courier"&gt;api_date&amp;gt;nwkdom(&lt;/FONT&gt;...&lt;FONT face="courier new,courier"&gt;)&lt;/FONT&gt;&amp;nbsp;evaluates to either 1 (true) or 0 (false) depending on whether &lt;FONT face="courier new,courier"&gt;api_date&lt;/FONT&gt; falls after the last Friday of the month or not. So, the first argument of the &lt;A href="https://documentation.sas.com/?cdcId=pgmsascdc&amp;amp;cdcVersion=9.4_3.4&amp;amp;docsetId=lefunctionsref&amp;amp;docsetTarget=n0mlfb88dkhbmun1x08qbh5xbs7e.htm&amp;amp;locale=en" target="_blank"&gt;PUT&lt;/A&gt; function amounts to either&amp;nbsp;&lt;FONT face="courier new,courier"&gt;intnx('month',api_date,1)&lt;/FONT&gt; or &lt;FONT face="courier new,courier"&gt;intnx('month',api_date,0)&lt;/FONT&gt;.&lt;/LI&gt;
&lt;LI&gt;The &lt;A href="https://documentation.sas.com/?cdcId=pgmsascdc&amp;amp;cdcVersion=9.4_3.4&amp;amp;docsetId=lefunctionsref&amp;amp;docsetTarget=p10v3sa3i4kfxfn1sovhi5xzxh8n.htm&amp;amp;locale=en" target="_blank"&gt;INTNX&lt;/A&gt; function in turn computes a SAS date value from the &lt;EM&gt;next&lt;/EM&gt;&amp;nbsp;month (third argument 1) or the &lt;EM&gt;same&lt;/EM&gt; month&amp;nbsp;&lt;SPAN&gt;(third argument 0)&lt;/SPAN&gt;&amp;nbsp;&lt;FONT face="courier new,courier"&gt;api_date&lt;/FONT&gt;&amp;nbsp;falls into, namely the &lt;EM&gt;beginning&lt;/EM&gt; of the respective month (see default value of the &lt;EM&gt;fourth&lt;/EM&gt; argument, '&lt;EM&gt;alignment&lt;/EM&gt;', in the &lt;A href="https://documentation.sas.com/?cdcId=pgmsascdc&amp;amp;cdcVersion=9.4_3.4&amp;amp;docsetId=lefunctionsref&amp;amp;docsetTarget=p10v3sa3i4kfxfn1sovhi5xzxh8n.htm&amp;amp;locale=en#p11jca64z7ugarn1f65kiq9r3pip" target="_blank"&gt;documentation of INTNX&lt;/A&gt;).&lt;/LI&gt;
&lt;LI&gt;Finally, the PUT function converts the SAS date value obtained&amp;nbsp;by INTNX into a seven-character string of the form YYYY-MM, e.g. 21397 (='01AUG2018'd) into '2018-08'.*&lt;/LI&gt;
&lt;/OL&gt;
&lt;P&gt;The result is what you&amp;nbsp;desired&amp;nbsp;as the&amp;nbsp;month of invoice: The "next" month if &lt;FONT face="courier new,courier"&gt;api_date&lt;/FONT&gt; falls after the last Friday of the month and the "current" month otherwise. You can use this expression in a GROUP BY clause as was suggested by DBailey in the other thread (&lt;FONT face="courier new,courier"&gt;calculated period&lt;/FONT&gt;). The other two expressions in the&amp;nbsp;&lt;SPAN&gt;GROUP BY clause can be defined in a similar way.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;*Edit: Feel free to use a different format in place of &lt;A title="yymmd7." href="https://documentation.sas.com/?cdcId=pgmsascdc&amp;amp;cdcVersion=9.4_3.4&amp;amp;docsetId=leforinforref&amp;amp;docsetTarget=n1k45hxg0vxohqn1ktr8k1tnmrn1.htm&amp;amp;locale=en" target="_blank"&gt;&lt;FONT face="courier new,courier"&gt;yymmd7.&lt;/FONT&gt;&lt;/A&gt;, e.g. &lt;FONT face="courier new,courier"&gt;&lt;A href="https://documentation.sas.com/?cdcId=pgmsascdc&amp;amp;cdcVersion=9.4_3.4&amp;amp;docsetId=leforinforref&amp;amp;docsetTarget=n1anshj9oarqccn15eulfy9mnszl.htm&amp;amp;locale=en" target="_blank"&gt;monyy7.&lt;/A&gt;&lt;/FONT&gt;, as long as it aggregates SAS date values&amp;nbsp;on month-year level.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 07 Nov 2018 18:12:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Count-for-a-specific-date-range/m-p/511105#M2109</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2018-11-07T18:12:25Z</dc:date>
    </item>
    <item>
      <title>Re: Count for a specific date range</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Count-for-a-specific-date-range/m-p/511110#M2110</link>
      <description>Thank you for providing that clarification! What a great explanation! Im just still confused on how I would get the PeriodStart and Period End for what I need, using the intnx statement. Could you assist me with that?</description>
      <pubDate>Wed, 07 Nov 2018 18:20:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Count-for-a-specific-date-range/m-p/511110#M2110</guid>
      <dc:creator>aperansi</dc:creator>
      <dc:date>2018-11-07T18:20:33Z</dc:date>
    </item>
    <item>
      <title>Re: Count for a specific date range</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Count-for-a-specific-date-range/m-p/511117#M2114</link>
      <description>&lt;P&gt;similar to other solution....&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input api_date:mmddyy10. api_count;
format api_date mmddyy10. api_count 8.0;
datalines;
1/1/2017 125
8/2/2017 126
8/3/2017 127
8/4/2017 128
8/5/2017 129
8/6/2017 130
8/7/2017 131
8/8/2017 132
8/9/2017 133
8/10/2017 134
8/11/2017 135
8/12/2017 136
8/13/2017 137
8/14/2017 138
8/15/2017 139
8/16/2017 140
8/17/2017 141
8/18/2017 142
8/19/2017 143
8/20/2017 144
8/21/2017 145
8/22/2017 146
8/23/2017 147
8/24/2017 148
8/25/2017 149
8/26/2017 150
8/27/2017 151
8/28/2017 152
8/29/2017 153
8/30/2017 154
8/31/2017 155
9/1/2017 156
9/2/2017 157
9/3/2017 158
9/4/2017 159
9/5/2017 160
9/6/2017 161
;
run;

proc sql;
create table want as select		
	intnx('month',api_date,case when api_date&amp;gt;=nwkdom(5,6,month(api_date),year(api_date)) then 1 else 0 end,'begin') format mmddyy10. as  Period,
	case
		/*if api_date &amp;gt;= last saturday of current month then use last saturday of current month*/
		when api_date &amp;gt;=nwkdom(5,6,month(api_date),year(api_date)) then nwkdom(5,6,month(api_date),year(api_date))
		/*else use last saturday of previous month*/
		else nwkdom(5,6,month(intnx('month',api_date,-1,'same')),year(intnx('month',api_date,-1,'same')))
		end format mmddyy10. as PeriodStart,
	case
		/*if api_date &amp;gt;= last saturday of current month then use last saturday of next month*/
		when api_date &amp;gt;=nwkdom(5,6,month(api_date),year(api_date)) then nwkdom(5,6,month(intnx('month',api_date,1,'same')),year(intnx('month',api_date,1,'same')))
		/*else use last saturday of current month*/
		else nwkdom(5,6,month(api_date),year(api_date))
		end 
		/*and backup one day from that*/
		-1 format mmddyy10. as PeriodEnd,
	sum(api_count) as Total_API_Count
from	
	have
group by
	calculated period
	,calculated periodstart
	,calculated periodEnd
;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 07 Nov 2018 18:43:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Count-for-a-specific-date-range/m-p/511117#M2114</guid>
      <dc:creator>DBailey</dc:creator>
      <dc:date>2018-11-07T18:43:22Z</dc:date>
    </item>
    <item>
      <title>Re: Count for a specific date range</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Count-for-a-specific-date-range/m-p/511179#M2127</link>
      <description>&lt;P&gt;Okay. Again, we have to distinguish between two cases:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;api_date falls after the last Friday of the month.&lt;BR /&gt;In this case PeriodStart is the last Saturday of the same month or, equivalently, the day after the last Friday of that month.&lt;BR /&gt;&lt;BR /&gt;PeriodEnd is the last Friday of the next month.&lt;BR /&gt;&lt;BR /&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;SPAN&gt;api_date does &lt;EM&gt;not&lt;/EM&gt; fall after the last Friday of the month.&lt;BR /&gt;In this case PeriodStart is the day after the last Friday of the &lt;EM&gt;previous&lt;/EM&gt; month. (Note that there was an ambiguity in your definition where you wrote "last Saturday&amp;nbsp;of the previous month"! Your example of August 2018, however, resolved this ambiguity: Instead of&amp;nbsp;"last Saturday&amp;nbsp;of the previous month" you meant&amp;nbsp;"the day after the last Friday of the previous month" [which can be the first day of the current month!]. Otherwise, the last few days of August 2018 would appear&amp;nbsp;&lt;EM&gt;again&lt;/EM&gt; in the September invoice!)&lt;BR /&gt;&lt;BR /&gt;PeriodEnd is the last Friday of the current month.&lt;BR /&gt;&lt;/SPAN&gt;&lt;/LI&gt;
&lt;/OL&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;So, we recognize a common pattern:&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;PeriodStart =&amp;nbsp;nwkdom(5,6,&lt;EM&gt;m&lt;/EM&gt;,&lt;EM&gt;y&lt;/EM&gt;)+1 for certain month-year combinations (&lt;EM&gt;m&lt;/EM&gt;, &lt;EM&gt;y&lt;/EM&gt;) depending on the&amp;nbsp;case. More precisely:&lt;/SPAN&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;EM&gt;m&lt;/EM&gt;=month(intnx('month', api_date, (api_date&amp;gt;nwkdom(5,6,month(api_date),year(api_date)))-1))
&lt;EM&gt;y&lt;/EM&gt;= year(intnx('month', api_date, (api_date&amp;gt;nwkdom(5,6,month(api_date),year(api_date)))-1))&lt;/PRE&gt;
&lt;P&gt;So, the final expression&amp;nbsp;for PeriodStart can be written as&lt;/P&gt;
&lt;PRE&gt;nwkdom(5,6,month(intnx('month', api_date, (api_date&amp;gt;nwkdom(5,6,month(api_date),year(api_date)))-1)),year(intnx('month', api_date, (api_date&amp;gt;nwkdom(5,6,month(api_date),year(api_date)))-1)))+1&lt;/PRE&gt;
&lt;P&gt;An equivalent and perhaps better readable CASE expression (assuming you want to use PROC SQL) is:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;case when api_date&amp;gt;nwkdom(5,6,month(api_date),year(api_date)) then nwkdom(5,7,month(api_date),year(api_date))
     else nwkdom(5,6,month(intnx('month',api_date,-1)),year(intnx('month',api_date,-1)))+1
end&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;(Note that I use &lt;FONT face="courier new,courier"&gt;nwkdom(5,&lt;STRONG&gt;7&lt;/STRONG&gt;,...)&lt;/FONT&gt;, i.e. last &lt;EM&gt;Saturday&lt;/EM&gt; in one place, as explained above.)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Similarly, PeriodEnd can be written as&lt;/P&gt;
&lt;PRE&gt;nwkdom(5,6,month(intnx('month', api_date, api_date&amp;gt;nwkdom(5,6,month(api_date),year(api_date)))),year(intnx('month',api_date,api_date&amp;gt;nwkdom(5,6,month(api_date),year(api_date)))))&lt;/PRE&gt;
&lt;P&gt;or, equivalently, as&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;case when api_date&amp;gt;nwkdom(5,6,month(api_date),year(api_date)) then nwkdom(5,6,month(intnx('month',api_date,1)),year(intnx('month',api_date,1)))
     else nwkdom(5,6,month(api_date),year(api_date))
end&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;All these expressions are quite lengthy. Maybe there is a more elegant way to define these non-standard intervals as &lt;EM&gt;custom intervals&lt;/EM&gt; which can be used in the INTNX (and INTCK) function (see documentation).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And definitely there are other ways to compute the (invoice-)monthly totals. Here is an example:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/* Create a format to assign the "invoice month" to a given date */

data invmonf / view=invmonf;
fmtname='invmonf';
do start='01AUG2017'd to '31DEC2020'd; /* modify the range as appropriate */
  label=put(intnx('month',start,start&amp;gt;nwkdom(5,6,month(start),year(start))),yymmd7.);
  output;
end;
format start weekdate.;
run;

proc format cntlin=invmonf;
run;

/* Compute total counts for each "invoice month" */

proc summary data=have nway;
format api_date invmonf.;
class api_date;
var count;
output out=mtotals(drop=_: rename=(api_date=invoice_month)) sum=;
run;

proc print data=mtotals;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 07 Nov 2018 20:21:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Count-for-a-specific-date-range/m-p/511179#M2127</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2018-11-07T20:21:32Z</dc:date>
    </item>
    <item>
      <title>Re: Count for a specific date range</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Count-for-a-specific-date-range/m-p/511185#M2128</link>
      <description>&lt;P&gt;Interesting, I've just noticed that&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13871"&gt;@DBailey&lt;/a&gt;&amp;nbsp;had posted another reply. A quick comparison of the results (for made-up&amp;nbsp;input data) has revealed &lt;EM&gt;that they differ! &lt;/EM&gt;I leave it to you,&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/228641"&gt;@aperansi&lt;/a&gt;, to decide which solution is correct for your purposes. (I'd use your example, the invoice for August 2018, to find out.)&lt;/P&gt;</description>
      <pubDate>Wed, 07 Nov 2018 20:29:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Count-for-a-specific-date-range/m-p/511185#M2128</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2018-11-07T20:29:59Z</dc:date>
    </item>
  </channel>
</rss>

