<?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 Error while merging two dataset proc sql : URGENT HELP in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Error-while-merging-two-dataset-proc-sql-URGENT-HELP/m-p/825122#M35200</link>
    <description>&lt;P&gt;I am trying to merge many to many variables using proc sql. i am getting syntex error . can anyone please help what is syntex error is? please help. it's urgent&lt;/P&gt;&lt;P&gt;&amp;nbsp;BELOW IS MY CODE&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;proc sort data=pk_dose0;&lt;BR /&gt;by nsid date time dose;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;proc sort data=dose_poppk;&lt;BR /&gt;by nsid date time dose;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;proc sql;&lt;BR /&gt;create table aa as&lt;BR /&gt;select * from pk_dose0 as a join dose_poppk as b on&lt;BR /&gt;(a.nsid=b.nsid)&lt;BR /&gt;(a.date=b.date)&lt;BR /&gt;(a.time=b.time);&lt;BR /&gt;quit;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;proc sql;&lt;BR /&gt;create table both as&lt;BR /&gt;select&lt;BR /&gt;coalesce(a.nsid, b.nsid) as id,&lt;BR /&gt;coalesce(a.date, b.date) as date,&lt;BR /&gt;coalesce(a.time, b.time) as time,&lt;BR /&gt;farm&lt;BR /&gt;from&lt;BR /&gt;pk_dose0 as a full join&lt;BR /&gt;dose_poppk as b&lt;BR /&gt;on a.id = b.id,&lt;BR /&gt;on a.date = b.date,&lt;BR /&gt;on a.time = b.time);&lt;BR /&gt;quit;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;BELOW IS SCREENSHOT OF ERROR.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="srmakwana2009_0-1658639162905.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/73672i95A48080273BC9A1/image-size/medium?v=v2&amp;amp;px=400" role="button" title="srmakwana2009_0-1658639162905.png" alt="srmakwana2009_0-1658639162905.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sun, 24 Jul 2022 05:07:03 GMT</pubDate>
    <dc:creator>srmakwana2009</dc:creator>
    <dc:date>2022-07-24T05:07:03Z</dc:date>
    <item>
      <title>Error while merging two dataset proc sql : URGENT HELP</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Error-while-merging-two-dataset-proc-sql-URGENT-HELP/m-p/825122#M35200</link>
      <description>&lt;P&gt;I am trying to merge many to many variables using proc sql. i am getting syntex error . can anyone please help what is syntex error is? please help. it's urgent&lt;/P&gt;&lt;P&gt;&amp;nbsp;BELOW IS MY CODE&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;proc sort data=pk_dose0;&lt;BR /&gt;by nsid date time dose;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;proc sort data=dose_poppk;&lt;BR /&gt;by nsid date time dose;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;proc sql;&lt;BR /&gt;create table aa as&lt;BR /&gt;select * from pk_dose0 as a join dose_poppk as b on&lt;BR /&gt;(a.nsid=b.nsid)&lt;BR /&gt;(a.date=b.date)&lt;BR /&gt;(a.time=b.time);&lt;BR /&gt;quit;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;proc sql;&lt;BR /&gt;create table both as&lt;BR /&gt;select&lt;BR /&gt;coalesce(a.nsid, b.nsid) as id,&lt;BR /&gt;coalesce(a.date, b.date) as date,&lt;BR /&gt;coalesce(a.time, b.time) as time,&lt;BR /&gt;farm&lt;BR /&gt;from&lt;BR /&gt;pk_dose0 as a full join&lt;BR /&gt;dose_poppk as b&lt;BR /&gt;on a.id = b.id,&lt;BR /&gt;on a.date = b.date,&lt;BR /&gt;on a.time = b.time);&lt;BR /&gt;quit;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;BELOW IS SCREENSHOT OF ERROR.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="srmakwana2009_0-1658639162905.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/73672i95A48080273BC9A1/image-size/medium?v=v2&amp;amp;px=400" role="button" title="srmakwana2009_0-1658639162905.png" alt="srmakwana2009_0-1658639162905.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 24 Jul 2022 05:07:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Error-while-merging-two-dataset-proc-sql-URGENT-HELP/m-p/825122#M35200</guid>
      <dc:creator>srmakwana2009</dc:creator>
      <dc:date>2022-07-24T05:07:03Z</dc:date>
    </item>
    <item>
      <title>Re: Error while merging two dataset proc sql : URGENT HELP</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Error-while-merging-two-dataset-proc-sql-URGENT-HELP/m-p/825123#M35201</link>
      <description>&lt;P&gt;Commas in the logic instead of how to add the comparison logic. Only one ON per join and you use AND and OR, possibly with ( ) to group a condition to add to any comparison whether an ON( or WHERE) clause.&lt;/P&gt;
&lt;PRE&gt;proc sql;
create table both as
select
coalesce(a.nsid, b.nsid) as id,
coalesce(a.date, b.date) as date,
coalesce(a.time, b.time) as time,
farm
from
pk_dose0 as a full join
dose_poppk as b
on a.id = b.id
    &lt;FONT color="#008000"&gt;&lt;STRONG&gt;and&lt;/STRONG&gt; &lt;/FONT&gt;a.date = b.date
    &lt;FONT color="#008000"&gt;&lt;STRONG&gt;and&lt;/STRONG&gt; &lt;/FONT&gt;a.time = b.time;
quit;

 &lt;/PRE&gt;
&lt;P&gt;However you have another syntax problem with a ) after = b.time that does not have a matching (.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You likely have an additional logic issue understanding your problem: Use of coalesce(a.time, b.time) coupled with the join on a.time=b.time. With the JOIN requirement A.time would be the same as B.time always so the coalesce is basically not adding anything. IF you expect to have a missing A.time or B.time where coalesce would make sense then your JOIN criteria have to be significantly different. Same for the A.date and B.date.&lt;/P&gt;
&lt;P&gt;You did not actually describe what sort of comparison you want. A danger with posting code that does not work without a description of what is needed is that we will quite often &lt;STRONG&gt;assume&lt;/STRONG&gt; that the simplest thing that cleans up errors is what is needed.&lt;/P&gt;
&lt;P&gt;It may be that&amp;nbsp; what you wanted could be:&lt;/P&gt;
&lt;PRE&gt;proc sql;
create table both as
select
coalesce(a.nsid, b.nsid) as id,
coalesce(a.date, b.date) as date,
coalesce(a.time, b.time) as time,
farm
from
pk_dose0 as a full join
dose_poppk as b
on a.id = b.id
    and (a.date = b.date
         or a.time = b.time
        )
 ;
quit;&lt;/PRE&gt;
&lt;P&gt;This would be match on date or the time. But this might be a poor choice if you have the same times on different dates along with the same time on missing dates for the same Id variable values.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you actually expect to have missing values and then align them some how you need to provide example data of the two sets and how you expect the result to look after the match along with any matching rules.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Save yourself some time and instead of creating a PICTURE of the log just copy the text from the log. The on the forum open a text box using the &amp;lt;/&amp;gt; that appears above the message window and paste the text.&lt;/P&gt;</description>
      <pubDate>Sun, 24 Jul 2022 13:04:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Error-while-merging-two-dataset-proc-sql-URGENT-HELP/m-p/825123#M35201</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2022-07-24T13:04:21Z</dc:date>
    </item>
    <item>
      <title>Re: Error while merging two dataset proc sql : URGENT HELP</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Error-while-merging-two-dataset-proc-sql-URGENT-HELP/m-p/825137#M35202</link>
      <description>&lt;P&gt;In the join condition instead of , put 'and'&lt;/P&gt;</description>
      <pubDate>Sun, 24 Jul 2022 12:08:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Error-while-merging-two-dataset-proc-sql-URGENT-HELP/m-p/825137#M35202</guid>
      <dc:creator>tarheel13</dc:creator>
      <dc:date>2022-07-24T12:08:27Z</dc:date>
    </item>
  </channel>
</rss>

