<?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: How do I conduct same date of service query in SAS EG? in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-do-I-conduct-same-date-of-service-query-in-SAS-EG/m-p/293493#M20051</link>
    <description>&lt;P&gt;Please let me know if I need to clariy my question. Thanks!&lt;/P&gt;</description>
    <pubDate>Tue, 23 Aug 2016 17:15:00 GMT</pubDate>
    <dc:creator>sas81</dc:creator>
    <dc:date>2016-08-23T17:15:00Z</dc:date>
    <item>
      <title>How do I conduct same date of service query in SAS EG?</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-do-I-conduct-same-date-of-service-query-in-SAS-EG/m-p/293484#M20049</link>
      <description>&lt;P&gt;Hello!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would sincerely appreciate any insight on the following question below. Basically I&amp;nbsp;need a distinct count of the &amp;nbsp;cust_ids to identify item codes that were ordered on the same day by the same person. I have to complete this analysis by tomorrow. I&amp;nbsp;am grateful for &amp;nbsp;your time and &amp;nbsp;help!&lt;/P&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Example Dataset:&lt;/DIV&gt;&lt;DIV&gt;Date &amp;nbsp;Item_Code &amp;nbsp; item_desc cust_id&lt;/DIV&gt;&lt;DIV&gt;08/18/2016 1245 &amp;nbsp; &amp;nbsp; &amp;nbsp; Pizza &amp;nbsp; &amp;nbsp; 5555&lt;/DIV&gt;&lt;DIV&gt;09/17/2014 1245 &amp;nbsp; &amp;nbsp; &amp;nbsp; Pizza &amp;nbsp; &amp;nbsp; 4357&lt;/DIV&gt;&lt;DIV&gt;08/18/2016 3344 &amp;nbsp; &amp;nbsp; &amp;nbsp;Chicken 5555&lt;/DIV&gt;&lt;DIV&gt;09/17/2014 6742 &amp;nbsp; &amp;nbsp; &amp;nbsp; Bread &amp;nbsp; &amp;nbsp; 4357&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;10/10/2015 3217 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Salad &amp;nbsp; &amp;nbsp; 3218&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;I am open to any format for the code and&amp;nbsp; final data output as I will complete the analysis in excel. I just need to be able to answer the following quesion: What item_codes were ordered on the same day? How many distinct members per combination?&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Final analysis I am looking to answer:&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Pizza (1245) and Chicken (3344) 1 person&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Pizza (1245) and bread (3344) 1 person&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;DIV&gt;I am using SAS EG version 4.2&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Tue, 23 Aug 2016 16:03:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-do-I-conduct-same-date-of-service-query-in-SAS-EG/m-p/293484#M20049</guid>
      <dc:creator>sas81</dc:creator>
      <dc:date>2016-08-23T16:03:47Z</dc:date>
    </item>
    <item>
      <title>Re: How do I conduct same date of service query in SAS EG?</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-do-I-conduct-same-date-of-service-query-in-SAS-EG/m-p/293493#M20051</link>
      <description>&lt;P&gt;Please let me know if I need to clariy my question. Thanks!&lt;/P&gt;</description>
      <pubDate>Tue, 23 Aug 2016 17:15:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-do-I-conduct-same-date-of-service-query-in-SAS-EG/m-p/293493#M20051</guid>
      <dc:creator>sas81</dc:creator>
      <dc:date>2016-08-23T17:15:00Z</dc:date>
    </item>
    <item>
      <title>Re: How do I conduct same date of service query in SAS EG?</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-do-I-conduct-same-date-of-service-query-in-SAS-EG/m-p/293513#M20052</link>
      <description>&lt;P&gt;There is a better solution with&amp;nbsp;&lt;STRONG&gt;hash&lt;/STRONG&gt; object, I'm sure. &amp;nbsp;But assuming I understand you correctly...&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data codes;
infile datalines dlm=',';
length date 8 item_code 8 item_desc $ 10 cust_id 8;
format date date9.;
informat date mmddyy.;
input date Item_Code item_desc cust_id;
datalines;
08/18/2016,1245,Pizza,5555
09/17/2014,1245,Pizza,4357
08/18/2016,3344,Chicken,5555
09/17/2014,6742,Bread,4357
10/10/2015,3217,Salad,3218
08/18/2016,1245,Pizza,9999
09/17/2014,1245,Pizza,4357
08/18/2016,3344,Chicken,9999
;
run;

proc sort data=codes;
 by date cust_id Item_Code;
run;

/* assemble combos per day, per customer */
data sameday_combos(keep=date combo cust_id);
 length combo $ 40;
 retain combo prev_item;
 set codes;
 by date cust_id Item_Code ;
 if prev_item ^= item_code then do;
   combo = catx(',',item_code,combo);
   prev_item=item_code;
  end;
 if last.cust_id then do;
   output; call missing (combo,prev_item) ; 
   end;
run;

/* sum the # customers per combo, per day */
proc sql;
  create table cust_totals as
    select date, combo, count(cust_id) as Customers
    from sameday_combos
    group by date, combo;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Output:&lt;/P&gt;
&lt;P&gt;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/4688iF22085AF353340FA/image-size/original?v=v2&amp;amp;px=-1" border="0" alt="cid.png" title="cid.png" /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You might have wanted each item code to be in its own variable (item_code1, item_code2, etc.) per day. &amp;nbsp;That's more of a transpose operation, and you may be able to adopt the above to get that...&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Chris&lt;/P&gt;</description>
      <pubDate>Tue, 23 Aug 2016 17:58:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-do-I-conduct-same-date-of-service-query-in-SAS-EG/m-p/293513#M20052</guid>
      <dc:creator>ChrisHemedinger</dc:creator>
      <dc:date>2016-08-23T17:58:40Z</dc:date>
    </item>
    <item>
      <title>Re: How do I conduct same date of service query in SAS EG?</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-do-I-conduct-same-date-of-service-query-in-SAS-EG/m-p/293518#M20053</link>
      <description>&lt;P&gt;That is perfect Chris! I wish&amp;nbsp;I &amp;nbsp;could thank you a million times. I researched several white papers but couldn't find what I was looking for. I really appreciate your time.&lt;/P&gt;</description>
      <pubDate>Tue, 23 Aug 2016 18:15:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-do-I-conduct-same-date-of-service-query-in-SAS-EG/m-p/293518#M20053</guid>
      <dc:creator>sas81</dc:creator>
      <dc:date>2016-08-23T18:15:21Z</dc:date>
    </item>
  </channel>
</rss>

