<?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 Counting number of records active on a given day in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Counting-number-of-records-active-on-a-given-day/m-p/181623#M46257</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have a table with a list of records that are linked to a group ID. Each record has a start date and an end date. Each record is active during this date range: &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;TABLE border="1" class="jiveBorder" style="border: 1px solid #000000; width: 100%;"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;" valign="middle"&gt;&lt;STRONG&gt;Group ID&lt;/STRONG&gt;&lt;/TH&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;" valign="middle"&gt;Days Within Range for Group ID&lt;/TH&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;" valign="middle"&gt;Record&lt;/TH&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;" valign="middle"&gt;&lt;STRONG&gt;Start Date&lt;/STRONG&gt;&lt;/TH&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;" valign="middle"&gt;&lt;STRONG&gt;End Date&lt;/STRONG&gt;&lt;/TH&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px; text-align: center;"&gt;A&lt;/TD&gt;&lt;TD style="padding: 2px; text-align: center;"&gt;5&lt;/TD&gt;&lt;TD style="padding: 2px; text-align: center;"&gt;1&lt;/TD&gt;&lt;TD style="padding: 2px; text-align: center;"&gt;1&lt;/TD&gt;&lt;TD style="padding: 2px; text-align: center;"&gt;5&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px; text-align: center;"&gt;A&lt;/TD&gt;&lt;TD style="padding: 2px; text-align: center;"&gt;5&lt;/TD&gt;&lt;TD style="padding: 2px; text-align: center;"&gt;2&lt;/TD&gt;&lt;TD style="padding: 2px; text-align: center;"&gt;1&lt;/TD&gt;&lt;TD style="padding: 2px; text-align: center;"&gt;5&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px; text-align: center;"&gt;B&lt;/TD&gt;&lt;TD style="padding: 2px; text-align: center;"&gt;10&lt;/TD&gt;&lt;TD style="padding: 2px; text-align: center;"&gt;3&lt;/TD&gt;&lt;TD style="padding: 2px; text-align: center;"&gt;1&lt;/TD&gt;&lt;TD style="padding: 2px; text-align: center;"&gt;5&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px; text-align: center;"&gt;B&lt;/TD&gt;&lt;TD style="padding: 2px; text-align: center;"&gt;10&lt;/TD&gt;&lt;TD style="padding: 2px; text-align: center;"&gt;4&lt;/TD&gt;&lt;TD style="padding: 2px; text-align: center;"&gt;6&lt;/TD&gt;&lt;TD style="padding: 2px; text-align: center;"&gt;10&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P style="font-size: 13.3333330154419px;"&gt;&lt;/P&gt;&lt;P&gt;I am trying to calculate the average number of records that are active for a group ID on a given date e.g for group ID A this would be 2 (as both records are active on every day within the group ID range). For B this would be 1 as all days within the range have an active record, and neither one of the records overlap. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here is the approach that I have taken:&lt;/P&gt;&lt;P&gt;1 - Create a table listing all the dates within the total range of all group IDs&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data alldates ;&lt;/P&gt;&lt;P&gt;&amp;nbsp; do Date = '03jan2010'd to '03jan2015'd ;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; output ;&lt;/P&gt;&lt;P&gt;&amp;nbsp; end ;&lt;/P&gt;&lt;P&gt;&amp;nbsp; format Date date9. ;&lt;/P&gt;&lt;P&gt;run ;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;2 - Joining this with the record table. I matched on the group ID and where the date is within the Start Date and End date for each record. This then created a table listing all of the active days for each record i.e. a record active for 5 days will have 5 rows in this table&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;&amp;nbsp; create table record_active_day_summary as&lt;/P&gt;&lt;P&gt;&amp;nbsp; select * &lt;/P&gt;&lt;P&gt;&amp;nbsp; from &lt;SPAN style="font-size: 13.3333330154419px;"&gt; alldates&lt;/SPAN&gt; as a&lt;/P&gt;&lt;P&gt;&amp;nbsp; inner join&lt;/P&gt;&lt;P&gt;&amp;nbsp; record_info as b&lt;/P&gt;&lt;P&gt;&amp;nbsp; on&amp;nbsp; a.group=b.group&lt;/P&gt;&lt;P&gt;&amp;nbsp; where a.Date between b.Start_Date and b.&lt;SPAN style="font-size: 13.3333330154419px;"&gt;End_Date&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; quit;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;3 - Summarize this table by the average number of times each day appears for each group ID. This gives the final output that I'm looking for.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;&amp;nbsp; create table group_summary as&lt;/P&gt;&lt;P&gt;&amp;nbsp; Select distinct Group&lt;/P&gt;&lt;P&gt;&amp;nbsp; count(Date)/count(distinct Date) as Avg_Records_Per_Day&lt;/P&gt;&lt;P&gt;&amp;nbsp; from &lt;SPAN style="font-size: 13.3333330154419px;"&gt;record_active_day_summary&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; quit;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Does anybody have an recommendations on how I can speed this up? Ideally I would like to figure out a way to cut out&amp;nbsp; Step 2 - this is an intermediary&amp;nbsp; creating a huge data set for me (around 95 million rows).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks in advance!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 25 Feb 2015 15:32:49 GMT</pubDate>
    <dc:creator>Jing333</dc:creator>
    <dc:date>2015-02-25T15:32:49Z</dc:date>
    <item>
      <title>Counting number of records active on a given day</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Counting-number-of-records-active-on-a-given-day/m-p/181623#M46257</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have a table with a list of records that are linked to a group ID. Each record has a start date and an end date. Each record is active during this date range: &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;TABLE border="1" class="jiveBorder" style="border: 1px solid #000000; width: 100%;"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;" valign="middle"&gt;&lt;STRONG&gt;Group ID&lt;/STRONG&gt;&lt;/TH&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;" valign="middle"&gt;Days Within Range for Group ID&lt;/TH&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;" valign="middle"&gt;Record&lt;/TH&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;" valign="middle"&gt;&lt;STRONG&gt;Start Date&lt;/STRONG&gt;&lt;/TH&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;" valign="middle"&gt;&lt;STRONG&gt;End Date&lt;/STRONG&gt;&lt;/TH&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px; text-align: center;"&gt;A&lt;/TD&gt;&lt;TD style="padding: 2px; text-align: center;"&gt;5&lt;/TD&gt;&lt;TD style="padding: 2px; text-align: center;"&gt;1&lt;/TD&gt;&lt;TD style="padding: 2px; text-align: center;"&gt;1&lt;/TD&gt;&lt;TD style="padding: 2px; text-align: center;"&gt;5&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px; text-align: center;"&gt;A&lt;/TD&gt;&lt;TD style="padding: 2px; text-align: center;"&gt;5&lt;/TD&gt;&lt;TD style="padding: 2px; text-align: center;"&gt;2&lt;/TD&gt;&lt;TD style="padding: 2px; text-align: center;"&gt;1&lt;/TD&gt;&lt;TD style="padding: 2px; text-align: center;"&gt;5&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px; text-align: center;"&gt;B&lt;/TD&gt;&lt;TD style="padding: 2px; text-align: center;"&gt;10&lt;/TD&gt;&lt;TD style="padding: 2px; text-align: center;"&gt;3&lt;/TD&gt;&lt;TD style="padding: 2px; text-align: center;"&gt;1&lt;/TD&gt;&lt;TD style="padding: 2px; text-align: center;"&gt;5&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px; text-align: center;"&gt;B&lt;/TD&gt;&lt;TD style="padding: 2px; text-align: center;"&gt;10&lt;/TD&gt;&lt;TD style="padding: 2px; text-align: center;"&gt;4&lt;/TD&gt;&lt;TD style="padding: 2px; text-align: center;"&gt;6&lt;/TD&gt;&lt;TD style="padding: 2px; text-align: center;"&gt;10&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P style="font-size: 13.3333330154419px;"&gt;&lt;/P&gt;&lt;P&gt;I am trying to calculate the average number of records that are active for a group ID on a given date e.g for group ID A this would be 2 (as both records are active on every day within the group ID range). For B this would be 1 as all days within the range have an active record, and neither one of the records overlap. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here is the approach that I have taken:&lt;/P&gt;&lt;P&gt;1 - Create a table listing all the dates within the total range of all group IDs&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data alldates ;&lt;/P&gt;&lt;P&gt;&amp;nbsp; do Date = '03jan2010'd to '03jan2015'd ;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; output ;&lt;/P&gt;&lt;P&gt;&amp;nbsp; end ;&lt;/P&gt;&lt;P&gt;&amp;nbsp; format Date date9. ;&lt;/P&gt;&lt;P&gt;run ;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;2 - Joining this with the record table. I matched on the group ID and where the date is within the Start Date and End date for each record. This then created a table listing all of the active days for each record i.e. a record active for 5 days will have 5 rows in this table&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;&amp;nbsp; create table record_active_day_summary as&lt;/P&gt;&lt;P&gt;&amp;nbsp; select * &lt;/P&gt;&lt;P&gt;&amp;nbsp; from &lt;SPAN style="font-size: 13.3333330154419px;"&gt; alldates&lt;/SPAN&gt; as a&lt;/P&gt;&lt;P&gt;&amp;nbsp; inner join&lt;/P&gt;&lt;P&gt;&amp;nbsp; record_info as b&lt;/P&gt;&lt;P&gt;&amp;nbsp; on&amp;nbsp; a.group=b.group&lt;/P&gt;&lt;P&gt;&amp;nbsp; where a.Date between b.Start_Date and b.&lt;SPAN style="font-size: 13.3333330154419px;"&gt;End_Date&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; quit;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;3 - Summarize this table by the average number of times each day appears for each group ID. This gives the final output that I'm looking for.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;&amp;nbsp; create table group_summary as&lt;/P&gt;&lt;P&gt;&amp;nbsp; Select distinct Group&lt;/P&gt;&lt;P&gt;&amp;nbsp; count(Date)/count(distinct Date) as Avg_Records_Per_Day&lt;/P&gt;&lt;P&gt;&amp;nbsp; from &lt;SPAN style="font-size: 13.3333330154419px;"&gt;record_active_day_summary&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; quit;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Does anybody have an recommendations on how I can speed this up? Ideally I would like to figure out a way to cut out&amp;nbsp; Step 2 - this is an intermediary&amp;nbsp; creating a huge data set for me (around 95 million rows).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks in advance!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 25 Feb 2015 15:32:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Counting-number-of-records-active-on-a-given-day/m-p/181623#M46257</guid>
      <dc:creator>Jing333</dc:creator>
      <dc:date>2015-02-25T15:32:49Z</dc:date>
    </item>
    <item>
      <title>Re: Counting number of records active on a given day</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Counting-number-of-records-active-on-a-given-day/m-p/181624#M46258</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;There's probably something better than this available, but here's an improved approach.&amp;nbsp; The effectiveness will depend on the date ranges that actually appear in your data, for each group_ID.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Summarize the record data first:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc summary data=record_info;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; by group_ID;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; var start_date end_date;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; output out=date_ranges (keep=group_ID range_begins range_ends)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; min(start_date) = range_begins&amp;nbsp; max(end_date) = range_ends;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;There are a few ways to proceed from here, but you won't have to process the full five years for every group_ID.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Good luck.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 25 Feb 2015 16:18:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Counting-number-of-records-active-on-a-given-day/m-p/181624#M46258</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2015-02-25T16:18:11Z</dc:date>
    </item>
    <item>
      <title>Re: Counting number of records active on a given day</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Counting-number-of-records-active-on-a-given-day/m-p/181625#M46259</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If all you care about is the average record-day on GroupID level, then It seems to me the key is to figure out the total number of Effective Days for each Groupid, taking consideration of gaps, overlaps etc. The following code is supposed to have better performance by leveraging Hash table:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="color: navy; background: white; font-family: 'Courier New';"&gt;&lt;STRONG&gt;data&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt; have;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-family: 'Courier New'; color: blue; background: white;"&gt;input&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt; GroupID$&amp;nbsp; record&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Start_Date End_Date;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-family: 'Courier New'; color: blue; background: white;"&gt;format&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt; Start_Date&amp;nbsp;&amp;nbsp;&amp;nbsp; End_Date &lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: teal; background: white;"&gt;date9.&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-family: 'Courier New'; color: blue; background: white;"&gt;cards&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: #FFFFC0;"&gt;A&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&amp;nbsp;&amp;nbsp;&amp;nbsp; 5&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: #FFFFC0;"&gt;A&amp;nbsp;&amp;nbsp;&amp;nbsp; 2&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&amp;nbsp;&amp;nbsp;&amp;nbsp; 5&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: #FFFFC0;"&gt;B&amp;nbsp;&amp;nbsp;&amp;nbsp; 3&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&amp;nbsp;&amp;nbsp;&amp;nbsp; 5&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: #FFFFC0;"&gt;B&amp;nbsp;&amp;nbsp;&amp;nbsp; 4&amp;nbsp;&amp;nbsp;&amp;nbsp; 6&amp;nbsp;&amp;nbsp;&amp;nbsp; 10&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: #FFFFC0;"&gt;C&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&amp;nbsp;&amp;nbsp;&amp;nbsp; 8&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: #FFFFC0;"&gt;C&amp;nbsp;&amp;nbsp;&amp;nbsp; 2&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&amp;nbsp;&amp;nbsp;&amp;nbsp; 5&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: #FFFFC0;"&gt;C&amp;nbsp;&amp;nbsp;&amp;nbsp; 3&amp;nbsp;&amp;nbsp;&amp;nbsp; 5&amp;nbsp;&amp;nbsp;&amp;nbsp; 10&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: #FFFFC0;"&gt;C&amp;nbsp;&amp;nbsp;&amp;nbsp; 4&amp;nbsp;&amp;nbsp;&amp;nbsp; 14&amp;nbsp;&amp;nbsp; 18&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-family: 'Courier New'; color: blue; background: white;"&gt;data&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt; want;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-family: 'Courier New'; color: blue; background: white;"&gt;dcl&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt; hash h(ordered:&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: purple; background: white;"&gt;'a'&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt;);&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; h.definekey(&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: purple; background: white;"&gt;'dt'&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt;);&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; h.definedone();&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-family: 'Courier New'; color: blue; background: white;"&gt;do&lt;/SPAN&gt; &lt;SPAN style="font-family: 'Courier New'; color: blue; background: white;"&gt;until&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt; (last.groupid);&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-family: 'Courier New'; color: blue; background: white;"&gt;set&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt; have;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-family: 'Courier New'; color: blue; background: white;"&gt;by&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt; groupid &lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: blue; background: white;"&gt;notsorted&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-family: 'Courier New'; color: blue; background: white;"&gt;do&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt; dt=start_date &lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: blue; background: white;"&gt;to&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt; end_date;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; rc=h.ref();&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-family: 'Courier New'; color: blue; background: white;"&gt;end&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; tot_rec_day+intck(&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: purple; background: white;"&gt;'day'&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt;, start_date, end_date)+&lt;/SPAN&gt;&lt;SPAN style="color: teal; background: white; font-family: 'Courier New';"&gt;&lt;STRONG&gt;1&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-family: 'Courier New'; color: blue; background: white;"&gt;end&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; avg_record=tot_rec_day/h.num_items;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-family: 'Courier New'; color: blue; background: white;"&gt;output&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; tot_rec_day=&lt;/SPAN&gt;&lt;SPAN style="color: teal; background: white; font-family: 'Courier New';"&gt;&lt;STRONG&gt;.&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-family: 'Courier New'; color: blue; background: white;"&gt;keep&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt; groupid tot_rec_day avg_record;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: navy; background: white; font-family: 'Courier New';"&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt;If you already have the accurate effective days for each groupid, as being presented, the following step may be skipped:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; tot_rec_day+intck(&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: purple; background: white;"&gt;'day'&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt;, start_date, end_date)+&lt;/SPAN&gt;&lt;SPAN style="color: teal; background: white; font-family: 'Courier New';"&gt;&lt;STRONG&gt;1&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt;instead, just go ahead use the range number came with your incoming data.&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Message was edited by: haikuo bian&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 25 Feb 2015 18:54:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Counting-number-of-records-active-on-a-given-day/m-p/181625#M46259</guid>
      <dc:creator>Haikuo</dc:creator>
      <dc:date>2015-02-25T18:54:49Z</dc:date>
    </item>
  </channel>
</rss>

