<?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: Counting swipes within two weeks in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Counting-swipes-within-two-weeks/m-p/615347#M179983</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/305683"&gt;@GregorClegane&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here is an attempt to answer your question. Let me know!&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
	input Member_ID Date_Swiped:date9.;
	format Date_Swiped date9.;
	datalines;
5299 04JAN2019
5299 05JAN2019
5299 11JAN2019
5299 14JAN2019
6023 05JUL2019
6023 02AUG2019
6023 20DEC2019
7288 01FEB2019
9588 31AUG2019
9588 02SEP2019
9855 04SEP2019
;
run;

proc sql noprint;
	select max(count) into:max_obs from (select count(Member_ID) as count from have group by Member_ID);
quit;

data ref;	
	set have;
	by Member_ID;
	format Date_Swiped_initial Start_range End_range date9.;
	if first.Member_ID then Date_Swiped_initial = Date_Swiped;
	retain Date_Swiped_initial;
	do i = 1 to &amp;amp;max_obs. by 2;
		Start_range = intnx('week',Date_Swiped_initial,i,"s")-7;
		End_range = Start_range + 13;
		output;
	end;
	drop i; 
run;

proc sql;
	create table want as
	select distinct a.member_id, a.Date_Swiped, b.Start_range, b.End_range
	from have as a inner join ref as b
	on b.Start_range &amp;lt;= a.Date_Swiped &amp;lt;= b.End_range and a.member_id = b.member_id ;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Mon, 06 Jan 2020 14:05:12 GMT</pubDate>
    <dc:creator>ed_sas_member</dc:creator>
    <dc:date>2020-01-06T14:05:12Z</dc:date>
    <item>
      <title>Counting swipes within two weeks</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Counting-swipes-within-two-weeks/m-p/615290#M179969</link>
      <description>&lt;P&gt;Good Morning!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have been struggling with the best way to approach this issue and I thought I would come on here and post.&amp;nbsp; I have a table with Employee ID along with check in dates.&amp;nbsp; I am trying to determine how to use SAS to first break up my dates into 2 week (14 day) chunks and then count the number of swipes (check in days within that 14 day period).&amp;nbsp; I was thinking about using min/max, but I think I would lose days if I did that.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So I am thinking my data will ultimately look like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Employee&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Date Range&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Swipes&lt;/P&gt;&lt;P&gt;Member001&amp;nbsp; &amp;nbsp;01JAN2019 - 14JAN2019&amp;nbsp; 16&lt;/P&gt;&lt;P&gt;Member001&amp;nbsp; &amp;nbsp;05MAR2019 - 19MAR2019 2&lt;/P&gt;&lt;P&gt;Member002&amp;nbsp; &amp;nbsp;02JAN2019 - 15JAN2019&amp;nbsp; 2&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Just not sure how to format that into proper SAS coding.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you for any guidance!&lt;/P&gt;</description>
      <pubDate>Mon, 06 Jan 2020 11:56:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Counting-swipes-within-two-weeks/m-p/615290#M179969</guid>
      <dc:creator>GregorClegane</dc:creator>
      <dc:date>2020-01-06T11:56:42Z</dc:date>
    </item>
    <item>
      <title>Re: Counting swipes within two weeks</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Counting-swipes-within-two-weeks/m-p/615301#M179972</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/305683"&gt;@GregorClegane&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Happy new Year and welcome to the community!&lt;/P&gt;
&lt;P&gt;Could you please share a sample of your input data so that we can help you?&lt;/P&gt;</description>
      <pubDate>Mon, 06 Jan 2020 12:30:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Counting-swipes-within-two-weeks/m-p/615301#M179972</guid>
      <dc:creator>ed_sas_member</dc:creator>
      <dc:date>2020-01-06T12:30:33Z</dc:date>
    </item>
    <item>
      <title>Re: Counting swipes within two weeks</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Counting-swipes-within-two-weeks/m-p/615303#M179973</link>
      <description>&lt;P&gt;Thank you for the welcome and Happy New Year!&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/292097"&gt;@ed_sas_member&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is a sample of the data that I have.&amp;nbsp; Just two columns so nothing huge.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Member_ID&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Swipe_Date&lt;/P&gt;&lt;P&gt;2115&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;12FEB2019&lt;/P&gt;&lt;P&gt;2115&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;13FEB2019&lt;/P&gt;&lt;P&gt;2115&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;14FEB2019&lt;/P&gt;&lt;P&gt;2115&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;17FEB2019&lt;/P&gt;&lt;P&gt;2115&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;19FEB2019&lt;/P&gt;&lt;P&gt;5192&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;20JUN2019&lt;/P&gt;&lt;P&gt;5192&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;30JUN2019&lt;/P&gt;&lt;P&gt;5192&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;20JUN2019&lt;/P&gt;&lt;P&gt;9528&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;04JAN2019&lt;/P&gt;&lt;P&gt;9528 &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;21JAN2019&lt;/P&gt;&lt;P&gt;9528 &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;24JAN2019&lt;/P&gt;</description>
      <pubDate>Mon, 06 Jan 2020 12:36:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Counting-swipes-within-two-weeks/m-p/615303#M179973</guid>
      <dc:creator>GregorClegane</dc:creator>
      <dc:date>2020-01-06T12:36:57Z</dc:date>
    </item>
    <item>
      <title>Re: Counting swipes within two weeks</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Counting-swipes-within-two-weeks/m-p/615327#M179980</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/292097"&gt;@ed_sas_member&lt;/a&gt;&amp;nbsp;and Happy New Year.&amp;nbsp; Thank you for the welcome&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is the sample data that I have.&amp;nbsp; Only two columns so not too bad.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Member_ID&amp;nbsp; &amp;nbsp; &amp;nbsp; Date_Swiped&lt;/P&gt;&lt;P&gt;5299&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;04JAN2019&lt;/P&gt;&lt;P&gt;5299&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;05JAN2019&lt;/P&gt;&lt;P&gt;5299&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;11JAN2019&lt;/P&gt;&lt;P&gt;5299&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;14JAN2019&lt;/P&gt;&lt;P&gt;6023&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 05JUL2019&lt;/P&gt;&lt;P&gt;6023&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 02AUG2019&lt;/P&gt;&lt;P&gt;6023&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 20DEC2019&lt;/P&gt;&lt;P&gt;7288&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 01FEB2019&lt;/P&gt;&lt;P&gt;9588&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;31AUG2019&lt;/P&gt;&lt;P&gt;9588&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 02SEP2019&lt;/P&gt;&lt;P&gt;9855&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 04SEP2019&lt;/P&gt;</description>
      <pubDate>Mon, 06 Jan 2020 13:22:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Counting-swipes-within-two-weeks/m-p/615327#M179980</guid>
      <dc:creator>GregorClegane</dc:creator>
      <dc:date>2020-01-06T13:22:51Z</dc:date>
    </item>
    <item>
      <title>Re: Counting swipes within two weeks</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Counting-swipes-within-two-weeks/m-p/615332#M179981</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/305683"&gt;@GregorClegane&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you for the sample data.&lt;/P&gt;
&lt;P&gt;Could you please specify also the desired output?&lt;/P&gt;
&lt;P&gt;What is the rule to identify the 14 days ? (e.g. the first day = the first check in date, the beginning of the month, etc.?)&lt;/P&gt;</description>
      <pubDate>Mon, 06 Jan 2020 13:35:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Counting-swipes-within-two-weeks/m-p/615332#M179981</guid>
      <dc:creator>ed_sas_member</dc:creator>
      <dc:date>2020-01-06T13:35:07Z</dc:date>
    </item>
    <item>
      <title>Re: Counting swipes within two weeks</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Counting-swipes-within-two-weeks/m-p/615334#M179982</link>
      <description>&lt;P&gt;Hey&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/292097"&gt;@ed_sas_member&lt;/a&gt;&amp;nbsp; the first day of the swipe would start the countdown for the first 14 days and encompass any dates from day 1 - day 14.&amp;nbsp; Then any other days after that would start the process of counting 14 over again.&lt;/P&gt;</description>
      <pubDate>Mon, 06 Jan 2020 13:36:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Counting-swipes-within-two-weeks/m-p/615334#M179982</guid>
      <dc:creator>GregorClegane</dc:creator>
      <dc:date>2020-01-06T13:36:57Z</dc:date>
    </item>
    <item>
      <title>Re: Counting swipes within two weeks</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Counting-swipes-within-two-weeks/m-p/615347#M179983</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/305683"&gt;@GregorClegane&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here is an attempt to answer your question. Let me know!&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
	input Member_ID Date_Swiped:date9.;
	format Date_Swiped date9.;
	datalines;
5299 04JAN2019
5299 05JAN2019
5299 11JAN2019
5299 14JAN2019
6023 05JUL2019
6023 02AUG2019
6023 20DEC2019
7288 01FEB2019
9588 31AUG2019
9588 02SEP2019
9855 04SEP2019
;
run;

proc sql noprint;
	select max(count) into:max_obs from (select count(Member_ID) as count from have group by Member_ID);
quit;

data ref;	
	set have;
	by Member_ID;
	format Date_Swiped_initial Start_range End_range date9.;
	if first.Member_ID then Date_Swiped_initial = Date_Swiped;
	retain Date_Swiped_initial;
	do i = 1 to &amp;amp;max_obs. by 2;
		Start_range = intnx('week',Date_Swiped_initial,i,"s")-7;
		End_range = Start_range + 13;
		output;
	end;
	drop i; 
run;

proc sql;
	create table want as
	select distinct a.member_id, a.Date_Swiped, b.Start_range, b.End_range
	from have as a inner join ref as b
	on b.Start_range &amp;lt;= a.Date_Swiped &amp;lt;= b.End_range and a.member_id = b.member_id ;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 06 Jan 2020 14:05:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Counting-swipes-within-two-weeks/m-p/615347#M179983</guid>
      <dc:creator>ed_sas_member</dc:creator>
      <dc:date>2020-01-06T14:05:12Z</dc:date>
    </item>
    <item>
      <title>Re: Counting swipes within two weeks</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Counting-swipes-within-two-weeks/m-p/615355#M179986</link>
      <description>&lt;P&gt;Thank you&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/292097"&gt;@ed_sas_member&lt;/a&gt;&amp;nbsp;it looks to work perfectly.&amp;nbsp; I am able to count the data based on the date ranges now.&amp;nbsp; I really appreciate the help!&lt;/P&gt;</description>
      <pubDate>Mon, 06 Jan 2020 14:32:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Counting-swipes-within-two-weeks/m-p/615355#M179986</guid>
      <dc:creator>GregorClegane</dc:creator>
      <dc:date>2020-01-06T14:32:39Z</dc:date>
    </item>
    <item>
      <title>Re: Counting swipes within two weeks</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Counting-swipes-within-two-weeks/m-p/615356#M179987</link>
      <description>&lt;P&gt;Thank you&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/305683"&gt;@GregorClegane&lt;/a&gt;&amp;nbsp;!&lt;/P&gt;
&lt;P&gt;Have a great day&lt;/P&gt;</description>
      <pubDate>Mon, 06 Jan 2020 14:33:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Counting-swipes-within-two-weeks/m-p/615356#M179987</guid>
      <dc:creator>ed_sas_member</dc:creator>
      <dc:date>2020-01-06T14:33:31Z</dc:date>
    </item>
  </channel>
</rss>

