<?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: Merging transaction dataset with a calendar dataset in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Merging-transaction-dataset-with-a-calendar-dataset/m-p/351613#M81848</link>
    <description>Hi Astounding,&lt;BR /&gt;&lt;BR /&gt;Thank you for your email..&lt;BR /&gt;I get an error when I  run  the code below. Is the syntax correct?&lt;BR /&gt;&lt;BR /&gt;Thank you&lt;BR /&gt;&lt;BR /&gt;*proc sql;*&lt;BR /&gt;&lt;BR /&gt;*create table want2 as*&lt;BR /&gt;&lt;BR /&gt;*select distinct owner from have1,*&lt;BR /&gt;&lt;BR /&gt;** from have2;*&lt;BR /&gt;&lt;BR /&gt;*order by owner date_id;*&lt;BR /&gt;&lt;BR /&gt;*quit;*&lt;BR /&gt;*##- Please *type your reply above this line. Simple formatting, no&lt;BR /&gt;attachments. -##</description>
    <pubDate>Thu, 20 Apr 2017 11:16:12 GMT</pubDate>
    <dc:creator>Question</dc:creator>
    <dc:date>2017-04-20T11:16:12Z</dc:date>
    <item>
      <title>Merging transaction dataset with a calendar dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Merging-transaction-dataset-with-a-calendar-dataset/m-p/351586#M81835</link>
      <description>&lt;P&gt;Hi All,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have the 2 datasets&amp;nbsp;attached&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;- First table contains the transactions dates of customer A and customer B&lt;/P&gt;
&lt;P&gt;- Second table containts the calendar dates and week_start_date and week_end_date ( from 01/01/2017 to 01/04/2017)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I want to merge the datasets and to produce one table contains both customers dates and calendar weeks but I want the same number rows than the calendar for each customer. For example if on 01/01/2017, they haven' transacted , I want to see a missing.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;When I use the code below, it works for the first customer but for the second, it only displays the dates when he transacted.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;data&lt;/STRONG&gt; want;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; merge &amp;nbsp;have 1 &amp;nbsp;(in=a)&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; have 2 &amp;nbsp;(in=b );&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; by date_id;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; if a;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Your help would be much appreciated&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank You&lt;/P&gt;</description>
      <pubDate>Thu, 20 Apr 2017 09:20:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Merging-transaction-dataset-with-a-calendar-dataset/m-p/351586#M81835</guid>
      <dc:creator>Question</dc:creator>
      <dc:date>2017-04-20T09:20:28Z</dc:date>
    </item>
    <item>
      <title>Re: Merging transaction dataset with a calendar dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Merging-transaction-dataset-with-a-calendar-dataset/m-p/351587#M81836</link>
      <description>&lt;P&gt;sorry the code is&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;data&lt;/STRONG&gt; want;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; merge &amp;nbsp;have 1 &amp;nbsp;(in=a)&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; have 2 &amp;nbsp;(in=b );&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; by date_id;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; if b;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;;&lt;/P&gt;</description>
      <pubDate>Thu, 20 Apr 2017 09:22:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Merging-transaction-dataset-with-a-calendar-dataset/m-p/351587#M81836</guid>
      <dc:creator>Question</dc:creator>
      <dc:date>2017-04-20T09:22:13Z</dc:date>
    </item>
    <item>
      <title>Re: Merging transaction dataset with a calendar dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Merging-transaction-dataset-with-a-calendar-dataset/m-p/351594#M81840</link>
      <description>&lt;P&gt;The result you are for is impractical. &amp;nbsp;There are multiple records that are identical, with no way (except their current order) to tell which customer they belong to.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;As an approach, you will need to add another variable that indicates the "owning" customer. &amp;nbsp;For example:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data want1;&lt;/P&gt;
&lt;P&gt;set have1;&lt;/P&gt;
&lt;P&gt;owner = customer_id;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc sql;&lt;/P&gt;
&lt;P&gt;create table want2 as&lt;/P&gt;
&lt;P&gt;select distinct owner from have1,&lt;/P&gt;
&lt;P&gt;* from have2;&lt;/P&gt;
&lt;P&gt;order by owner date_id;&lt;/P&gt;
&lt;P&gt;quit;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data want;&lt;/P&gt;
&lt;P&gt;merge want1 want2;&lt;/P&gt;
&lt;P&gt;by owner date_id;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Keep the extra variable OWNER in there. &amp;nbsp;You don't have to print it, but you will need it for any sort of analysis.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 20 Apr 2017 10:36:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Merging-transaction-dataset-with-a-calendar-dataset/m-p/351594#M81840</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2017-04-20T10:36:03Z</dc:date>
    </item>
    <item>
      <title>Re: Merging transaction dataset with a calendar dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Merging-transaction-dataset-with-a-calendar-dataset/m-p/351613#M81848</link>
      <description>Hi Astounding,&lt;BR /&gt;&lt;BR /&gt;Thank you for your email..&lt;BR /&gt;I get an error when I  run  the code below. Is the syntax correct?&lt;BR /&gt;&lt;BR /&gt;Thank you&lt;BR /&gt;&lt;BR /&gt;*proc sql;*&lt;BR /&gt;&lt;BR /&gt;*create table want2 as*&lt;BR /&gt;&lt;BR /&gt;*select distinct owner from have1,*&lt;BR /&gt;&lt;BR /&gt;** from have2;*&lt;BR /&gt;&lt;BR /&gt;*order by owner date_id;*&lt;BR /&gt;&lt;BR /&gt;*quit;*&lt;BR /&gt;*##- Please *type your reply above this line. Simple formatting, no&lt;BR /&gt;attachments. -##</description>
      <pubDate>Thu, 20 Apr 2017 11:16:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Merging-transaction-dataset-with-a-calendar-dataset/m-p/351613#M81848</guid>
      <dc:creator>Question</dc:creator>
      <dc:date>2017-04-20T11:16:12Z</dc:date>
    </item>
    <item>
      <title>Re: Merging transaction dataset with a calendar dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Merging-transaction-dataset-with-a-calendar-dataset/m-p/351656#M81870</link>
      <description>&lt;P&gt;My fault.&amp;nbsp; I added ORDER BY as an afterthought.&amp;nbsp; The semicolon on the previous line should be removed.&lt;/P&gt;</description>
      <pubDate>Thu, 20 Apr 2017 13:07:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Merging-transaction-dataset-with-a-calendar-dataset/m-p/351656#M81870</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2017-04-20T13:07:25Z</dc:date>
    </item>
    <item>
      <title>Re: Merging transaction dataset with a calendar dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Merging-transaction-dataset-with-a-calendar-dataset/m-p/351685#M81878</link>
      <description>Hi Astounding,&lt;BR /&gt;&lt;BR /&gt;I have removed the semicolon, but still get error. The error comes from&lt;BR /&gt;this highlighetd in red (*from have2)&lt;BR /&gt;&lt;BR /&gt;Thank you&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;proc sql;&lt;BR /&gt;&lt;BR /&gt;create table want2 as&lt;BR /&gt;&lt;BR /&gt;select distinct owner from have1,&lt;BR /&gt;&lt;BR /&gt;* from have2&lt;BR /&gt;&lt;BR /&gt;order by owner date_id;&lt;BR /&gt;&lt;BR /&gt;quit;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;##- Please type your reply above this line. Simple formatting, no&lt;BR /&gt;attachments. -##</description>
      <pubDate>Thu, 20 Apr 2017 13:54:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Merging-transaction-dataset-with-a-calendar-dataset/m-p/351685#M81878</guid>
      <dc:creator>Question</dc:creator>
      <dc:date>2017-04-20T13:54:01Z</dc:date>
    </item>
    <item>
      <title>Re: Merging transaction dataset with a calendar dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Merging-transaction-dataset-with-a-calendar-dataset/m-p/351688#M81879</link>
      <description>&lt;P&gt;Rather than posting the program, you will need to post the log.&amp;nbsp; That's what explains the nature of the error.&lt;/P&gt;</description>
      <pubDate>Thu, 20 Apr 2017 13:57:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Merging-transaction-dataset-with-a-calendar-dataset/m-p/351688#M81879</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2017-04-20T13:57:19Z</dc:date>
    </item>
    <item>
      <title>Re: Merging transaction dataset with a calendar dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Merging-transaction-dataset-with-a-calendar-dataset/m-p/351695#M81880</link>
      <description>Please find below the log. Thank you&lt;BR /&gt;&lt;BR /&gt;NOTE: Writing TAGSETS.SASREPORT13(EGSR) Body file: EGSR&lt;BR /&gt;22&lt;BR /&gt;23         GOPTIONS ACCESSIBLE;&lt;BR /&gt;24         proc sql;&lt;BR /&gt;25&lt;BR /&gt;26         create table work.want2 as&lt;BR /&gt;27&lt;BR /&gt;28         select distinct owner from work.OC_12w_trans,&lt;BR /&gt;29&lt;BR /&gt;30         * from work.events_all_12w&lt;BR /&gt;           _&lt;BR /&gt;           22&lt;BR /&gt;           76&lt;BR /&gt;ERROR 22-322: Syntax error, expecting one of the following: a name, a&lt;BR /&gt;quoted string, (, CONNECTION, DICTIONARY.&lt;BR /&gt;&lt;BR /&gt;ERROR 76-322: Syntax error, statement will be ignored.&lt;BR /&gt;&lt;BR /&gt;31&lt;BR /&gt;32         order by owner date_id;&lt;BR /&gt;NOTE: PROC SQL set option NOEXEC and will continue to check the syntax of&lt;BR /&gt;statements.&lt;BR /&gt;33&lt;BR /&gt;34         quit;&lt;BR /&gt;NOTE: The SAS System stopped processing this step because of errors.&lt;BR /&gt;NOTE: PROCEDURE SQL used (Total process time):&lt;BR /&gt;      real time           0.00 seconds&lt;BR /&gt;      cpu time            0.00 seconds&lt;BR /&gt;&lt;BR /&gt;##- Please type your reply above this line. Simple formatting, no&lt;BR /&gt;attachments. -##</description>
      <pubDate>Thu, 20 Apr 2017 14:08:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Merging-transaction-dataset-with-a-calendar-dataset/m-p/351695#M81880</guid>
      <dc:creator>Question</dc:creator>
      <dc:date>2017-04-20T14:08:01Z</dc:date>
    </item>
    <item>
      <title>Re: Merging transaction dataset with a calendar dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Merging-transaction-dataset-with-a-calendar-dataset/m-p/351699#M81883</link>
      <description>&lt;P&gt;OK.&amp;nbsp; I'm sure there are SQL guys out there that can do this in one step.&amp;nbsp; But my SQL isn't the strongest, so here's a two-step version:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc sql;&lt;/P&gt;
&lt;P&gt;create table owner_list as&lt;/P&gt;
&lt;P&gt;select distinct owner from have1;&lt;/P&gt;
&lt;P&gt;create table want2 as&lt;/P&gt;
&lt;P&gt;select * from have2, owner_list&lt;/P&gt;
&lt;P&gt;order by owner date_id;&lt;/P&gt;
&lt;P&gt;quit;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Hoping that's the last change!&lt;/P&gt;</description>
      <pubDate>Thu, 20 Apr 2017 14:20:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Merging-transaction-dataset-with-a-calendar-dataset/m-p/351699#M81883</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2017-04-20T14:20:25Z</dc:date>
    </item>
    <item>
      <title>Re: Merging transaction dataset with a calendar dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Merging-transaction-dataset-with-a-calendar-dataset/m-p/351720#M81889</link>
      <description>Thank You for your help Astounding! It now works &lt;span class="lia-unicode-emoji" title=":smiling_face_with_smiling_eyes:"&gt;😊&lt;/span&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;##- Please type your reply above this line. Simple formatting, no&lt;BR /&gt;attachments. -##</description>
      <pubDate>Thu, 20 Apr 2017 14:50:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Merging-transaction-dataset-with-a-calendar-dataset/m-p/351720#M81889</guid>
      <dc:creator>Question</dc:creator>
      <dc:date>2017-04-20T14:50:01Z</dc:date>
    </item>
  </channel>
</rss>

