<?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: Randomly select 1000 10-day periods in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Count-number-of-observations-in-10-day-periods/m-p/478178#M286312</link>
    <description>&lt;P&gt;Why? You might as well calculate the number of distinct IDs for every 10-day period. That's fewer than 1000/year.&lt;/P&gt;</description>
    <pubDate>Sun, 15 Jul 2018 05:20:56 GMT</pubDate>
    <dc:creator>PGStats</dc:creator>
    <dc:date>2018-07-15T05:20:56Z</dc:date>
    <item>
      <title>Count number of observations in 10-day periods</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Count-number-of-observations-in-10-day-periods/m-p/478173#M286311</link>
      <description>&lt;P&gt;Hello, I have a dataset with more than 20 million observations covering 40 years. Dataset is in below form&lt;/P&gt;&lt;P&gt;date&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; id1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; var1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;var2&amp;nbsp; &amp;nbsp; date1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;date2&lt;/P&gt;&lt;P&gt;01012000&amp;nbsp; &amp;nbsp; &amp;nbsp;14780&amp;nbsp; &amp;nbsp;3&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;5&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 06202000&amp;nbsp; &amp;nbsp; &amp;nbsp;06292000&lt;/P&gt;&lt;P&gt;07251977&amp;nbsp; &amp;nbsp; &amp;nbsp;25489&amp;nbsp; &amp;nbsp; 0.8&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1.9&amp;nbsp; &amp;nbsp; 09241977&amp;nbsp; &amp;nbsp; &amp;nbsp;10031977&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would like&amp;nbsp;to count&amp;nbsp;&lt;SPAN&gt;the number of observations&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;within each 10-day interval and get the average for all intervals each year except for the dates between date1 and date2.&lt;/SPAN&gt;&amp;nbsp;The output should give the average number of observations in all 10-day intervals for each year excluding the ones between date1 and date2. I would be very glad if you could help. Thanks!&lt;/P&gt;</description>
      <pubDate>Sun, 15 Jul 2018 05:49:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Count-number-of-observations-in-10-day-periods/m-p/478173#M286311</guid>
      <dc:creator>aword</dc:creator>
      <dc:date>2018-07-15T05:49:31Z</dc:date>
    </item>
    <item>
      <title>Re: Randomly select 1000 10-day periods</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Count-number-of-observations-in-10-day-periods/m-p/478178#M286312</link>
      <description>&lt;P&gt;Why? You might as well calculate the number of distinct IDs for every 10-day period. That's fewer than 1000/year.&lt;/P&gt;</description>
      <pubDate>Sun, 15 Jul 2018 05:20:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Count-number-of-observations-in-10-day-periods/m-p/478178#M286312</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2018-07-15T05:20:56Z</dc:date>
    </item>
    <item>
      <title>Re: Randomly select 1000 10-day periods</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Count-number-of-observations-in-10-day-periods/m-p/478180#M286313</link>
      <description>&lt;P&gt;Thanks for your reply. You are right, I edited the question.&lt;/P&gt;</description>
      <pubDate>Sun, 15 Jul 2018 05:47:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Count-number-of-observations-in-10-day-periods/m-p/478180#M286313</guid>
      <dc:creator>aword</dc:creator>
      <dc:date>2018-07-15T05:47:59Z</dc:date>
    </item>
    <item>
      <title>Re: Randomly select 1000 10-day periods</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Count-number-of-observations-in-10-day-periods/m-p/478181#M286314</link>
      <description>&lt;P&gt;A reasonably efficient way to get the distinct id counts for every 10-day period would be:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
proc sort data=have; by id date; run;

proc sql noprint;
select min(date) - 9, max(date) into :beg, :end
from test;
quit;

data want;
array pr{&amp;amp;beg:&amp;amp;end} _temporary_;
array cnt{&amp;amp;beg:&amp;amp;end} _temporary_;
call missing(of pr{*});
do until(last.id);
    set have end=done; by id;
    do i = date-9 to date;
        pr{i} = 1;
        end;
    end;
do i = &amp;amp;beg to &amp;amp;end;
    if pr{i} then cnt{i} = sum(cnt{i}, 1);
    end;
if done then do;
    do date = &amp;amp;beg + 9 to &amp;amp;end - 9;
        distinctId = coalesce(cnt{date}, 0);
        output;
        end;
    end;
label date="10-day period start date";
keep date distinctId;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 15 Jul 2018 06:18:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Count-number-of-observations-in-10-day-periods/m-p/478181#M286314</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2018-07-15T06:18:50Z</dc:date>
    </item>
    <item>
      <title>Re: Randomly select 1000 10-day periods</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Count-number-of-observations-in-10-day-periods/m-p/478219#M286315</link>
      <description>&lt;P&gt;Thanks for your help. Your code did not produce what I want. I am not sure why but the output has lots of zeros which is not expected for nearly any of the 10-day period. What I need is the number of rows in each 10-day period each year excluding the days between date1 and date2. I also need to know which count belongs to which 10-day period. So the output would seem like this for year 1977:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;10-day period&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;count&lt;/P&gt;&lt;P&gt;01.01.1977-01.10.1977&amp;nbsp; &amp;nbsp; &amp;nbsp; 125&lt;/P&gt;&lt;P&gt;01.02.1977-01.11.1977&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;230&lt;/P&gt;&lt;P&gt;01.03.1977-01.12.1977&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;195&lt;/P&gt;&lt;P&gt;.&lt;/P&gt;&lt;P&gt;.&lt;/P&gt;&lt;P&gt;.&lt;/P&gt;&lt;P&gt;09.14.1977-09.23.1977&amp;nbsp; &amp;nbsp; &amp;nbsp; 214 (here we exclude date1 09.24.1977- date2 10.03.1977 and jump to 10.04.1977)&lt;/P&gt;&lt;P&gt;10.04.1977-10.13.1977&amp;nbsp; &amp;nbsp; &amp;nbsp; 98&lt;/P&gt;&lt;P&gt;.&lt;/P&gt;&lt;P&gt;.&lt;/P&gt;&lt;P&gt;.&lt;/P&gt;&lt;P&gt;12.22.1977-12.31.1977&amp;nbsp; &amp;nbsp; &amp;nbsp;144&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I need this for all years and then I will calculate means and other stuff from here. I appreciate your help.&lt;/P&gt;</description>
      <pubDate>Sun, 15 Jul 2018 18:03:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Count-number-of-observations-in-10-day-periods/m-p/478219#M286315</guid>
      <dc:creator>aword</dc:creator>
      <dc:date>2018-07-15T18:03:03Z</dc:date>
    </item>
    <item>
      <title>Re: Randomly select 1000 10-day periods</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Count-number-of-observations-in-10-day-periods/m-p/478226#M286316</link>
      <description>&lt;P&gt;Post what you did.&lt;/P&gt;</description>
      <pubDate>Sun, 15 Jul 2018 19:00:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Count-number-of-observations-in-10-day-periods/m-p/478226#M286316</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2018-07-15T19:00:40Z</dc:date>
    </item>
    <item>
      <title>Re: Randomly select 1000 10-day periods</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Count-number-of-observations-in-10-day-periods/m-p/478237#M286317</link>
      <description>I don't have anything useful that would help right now.</description>
      <pubDate>Sun, 15 Jul 2018 20:51:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Count-number-of-observations-in-10-day-periods/m-p/478237#M286317</guid>
      <dc:creator>aword</dc:creator>
      <dc:date>2018-07-15T20:51:54Z</dc:date>
    </item>
  </channel>
</rss>

