<?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 Find repeating users between set weeks in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Find-repeating-users-between-set-weeks/m-p/893611#M353029</link>
    <description>&lt;P&gt;Hello!&lt;/P&gt;&lt;P&gt;I want to find repeated users who always do cash withdrawals between set weeks.&lt;/P&gt;&lt;P&gt;Right now I have it set up in a way where I have created tables for each week containing userid, transaction type and dates.&lt;/P&gt;&lt;P&gt;Tables: W1,W2,W3&lt;/P&gt;&lt;P&gt;Now to find the same users present every week I figure an inner join between the tables would do the job&lt;/P&gt;&lt;PRE&gt;PROC SQL;
Select a.id
FROM W1 A JOIN W2 B ON.. JOIN W3 C ON..
WHERE transaction type = ;
QUIT;&lt;/PRE&gt;&lt;P&gt;I assume this would give the common users each week?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But what if I have created one big table with all the dates included. How would I go about in finding the repeated users each week?&lt;/P&gt;&lt;P&gt;Would keeping the tables separate make more sense?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 11 Sep 2023 17:44:17 GMT</pubDate>
    <dc:creator>darklord</dc:creator>
    <dc:date>2023-09-11T17:44:17Z</dc:date>
    <item>
      <title>Find repeating users between set weeks</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Find-repeating-users-between-set-weeks/m-p/893611#M353029</link>
      <description>&lt;P&gt;Hello!&lt;/P&gt;&lt;P&gt;I want to find repeated users who always do cash withdrawals between set weeks.&lt;/P&gt;&lt;P&gt;Right now I have it set up in a way where I have created tables for each week containing userid, transaction type and dates.&lt;/P&gt;&lt;P&gt;Tables: W1,W2,W3&lt;/P&gt;&lt;P&gt;Now to find the same users present every week I figure an inner join between the tables would do the job&lt;/P&gt;&lt;PRE&gt;PROC SQL;
Select a.id
FROM W1 A JOIN W2 B ON.. JOIN W3 C ON..
WHERE transaction type = ;
QUIT;&lt;/PRE&gt;&lt;P&gt;I assume this would give the common users each week?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But what if I have created one big table with all the dates included. How would I go about in finding the repeated users each week?&lt;/P&gt;&lt;P&gt;Would keeping the tables separate make more sense?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 11 Sep 2023 17:44:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Find-repeating-users-between-set-weeks/m-p/893611#M353029</guid>
      <dc:creator>darklord</dc:creator>
      <dc:date>2023-09-11T17:44:17Z</dc:date>
    </item>
    <item>
      <title>Re: Find repeating users between set weeks</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Find-repeating-users-between-set-weeks/m-p/893632#M353033</link>
      <description>&lt;P&gt;IF you have actual SAS date values then Proc Summary and a careful selection of format should work for a long data set as described to find repeated users for a given week. This is the approach I would take instead of working with multiple tables.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;Proc summary data=have nway;
   class idvariable datevariable;
   format datevariable weeku5. ;
   output out=want (drop=_type_ where=(_freq_&amp;gt;1));
run;&lt;/PRE&gt;
&lt;P&gt;There are 3 different week formats, WeekU WeekV and WeekW with the differences being how the weeks crossing the calendar year are treated and the start day of a week.&lt;/P&gt;
&lt;P&gt;The output data set will have the two class variables and the automatic variable _freq_ for the count of the number of observations that have the class variable combination. The date variable will look something like 19W03 (week 3 of 2019) but is still a date variable and changing the format will make it appear "nicer".&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you don't like the format approach to creating group you could take another step in a data step or sql to use the INTNX function to add a variable that represents the start or end day of a week and use that to group on.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 11 Sep 2023 20:07:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Find-repeating-users-between-set-weeks/m-p/893632#M353033</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2023-09-11T20:07:10Z</dc:date>
    </item>
    <item>
      <title>Re: Find repeating users between set weeks</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Find-repeating-users-between-set-weeks/m-p/893642#M353039</link>
      <description>&lt;P&gt;To answer the SQL/Design part of it, no.&amp;nbsp; I would have one big table with the value of a week field differentiating between weeks.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I would try to go down the road&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13884"&gt;@ballardw&lt;/a&gt;&amp;nbsp;is suggesting.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you don't want to do that or don't understand it:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data transactions;
   input week customerid;
datalines;
1 1
2 1
3 1
4 1
5 1
6 1
1 2
3 2
6 2
;
run;


proc sql;
select 
customerid
from 
transactions
where
week &amp;gt;=2 and week&amp;lt;=4
group by customerid
having count(customerid) = 3;
quit; 
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;shows that&amp;nbsp;&lt;/P&gt;
&lt;TABLE width="123"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="123"&gt;customerid&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;1&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Customer 1 is your loyal weekly with this data.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 11 Sep 2023 20:38:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Find-repeating-users-between-set-weeks/m-p/893642#M353039</guid>
      <dc:creator>HB</dc:creator>
      <dc:date>2023-09-11T20:38:25Z</dc:date>
    </item>
    <item>
      <title>Re: Find repeating users between set weeks</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Find-repeating-users-between-set-weeks/m-p/893717#M353063</link>
      <description>Hello,&lt;BR /&gt;Thanks for this. It did help in the frequency of the users. Which helped in giving a nice picture of the repeat ones.&lt;BR /&gt;&lt;BR /&gt;I decided not to put the date in since it wasn't very much needed &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;</description>
      <pubDate>Tue, 12 Sep 2023 08:47:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Find-repeating-users-between-set-weeks/m-p/893717#M353063</guid>
      <dc:creator>darklord</dc:creator>
      <dc:date>2023-09-12T08:47:13Z</dc:date>
    </item>
    <item>
      <title>Re: Find repeating users between set weeks</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Find-repeating-users-between-set-weeks/m-p/893718#M353064</link>
      <description>Hello,&lt;BR /&gt;Thanks for the help, I did end up using what&lt;BR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13884"&gt;@ballardw&lt;/a&gt; suggested and it worked well!&lt;BR /&gt;Should keep summary in mind for next time use!</description>
      <pubDate>Tue, 12 Sep 2023 08:48:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Find-repeating-users-between-set-weeks/m-p/893718#M353064</guid>
      <dc:creator>darklord</dc:creator>
      <dc:date>2023-09-12T08:48:32Z</dc:date>
    </item>
  </channel>
</rss>

