<?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 Data Merge Help in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Data-Merge-Help/m-p/262119#M51098</link>
    <description>&lt;P&gt;I have two data sets both with the variable imb_code. I need to keep any records in QueryData that are not FinalData with the same imb_code.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can someone help me with my Merge sytax for this problem?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any help would be much appreciated.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sort data= QueryData;
by imb_code;
run;

proc sort data= FinalData;
by imb_code;
run;

data DATA_MERGED;
merge QueryData FinalData;
by imb_code;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Thu, 07 Apr 2016 16:05:07 GMT</pubDate>
    <dc:creator>buechler66</dc:creator>
    <dc:date>2016-04-07T16:05:07Z</dc:date>
    <item>
      <title>Data Merge Help</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Data-Merge-Help/m-p/262119#M51098</link>
      <description>&lt;P&gt;I have two data sets both with the variable imb_code. I need to keep any records in QueryData that are not FinalData with the same imb_code.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can someone help me with my Merge sytax for this problem?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any help would be much appreciated.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sort data= QueryData;
by imb_code;
run;

proc sort data= FinalData;
by imb_code;
run;

data DATA_MERGED;
merge QueryData FinalData;
by imb_code;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 07 Apr 2016 16:05:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Data-Merge-Help/m-p/262119#M51098</guid>
      <dc:creator>buechler66</dc:creator>
      <dc:date>2016-04-07T16:05:07Z</dc:date>
    </item>
    <item>
      <title>Re: Data Merge Help</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Data-Merge-Help/m-p/262124#M51100</link>
      <description>Take a look at the IN data set option. LOTS of examples our there if you search.</description>
      <pubDate>Thu, 07 Apr 2016 16:21:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Data-Merge-Help/m-p/262124#M51100</guid>
      <dc:creator>LinusH</dc:creator>
      <dc:date>2016-04-07T16:21:05Z</dc:date>
    </item>
    <item>
      <title>Re: Data Merge Help</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Data-Merge-Help/m-p/262125#M51101</link>
      <description>&lt;P&gt;Use the IN= dataset option.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data DATA_MERGED;
  merge QueryData FinalData(in=inFinalData);
  by imb_code;
  if not inFinalData;
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 07 Apr 2016 16:22:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Data-Merge-Help/m-p/262125#M51101</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2016-04-07T16:22:07Z</dc:date>
    </item>
    <item>
      <title>Re: Data Merge Help</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Data-Merge-Help/m-p/262132#M51105</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm stuck here where I'm trying to filter FinalData to keep only records where rule_order is &amp;lt; 997.1 before the merge actually happens.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;1378  data FinalData;
1379  merge QueryData (in=a) FinalData_2(in=b) (where= (rule_order &amp;lt; 997.1));
                                               -
                                               22
                                               76
ERROR 22-322: Syntax error, expecting one of the following: a name, a quoted string, ;, END, _DATA_, _LAST_, _NULL_.

ERROR 76-322: Syntax error, statement will be ignored.

1380  by imb_code;
1381  if a and not b;
1382  run;

NOTE: The SAS System stopped processing this step because of errors.
WARNING: The data set WORK.FINALDATA may be incomplete.  When this step was stopped there were 0 observations and 0 variables.
WARNING: Data set WORK.FINALDATA was not replaced because this step was stopped.
NOTE: DATA statement used (Total process time):
      real time           0.01 seconds
      cpu time            0.01 seconds&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 07 Apr 2016 16:58:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Data-Merge-Help/m-p/262132#M51105</guid>
      <dc:creator>buechler66</dc:creator>
      <dc:date>2016-04-07T16:58:34Z</dc:date>
    </item>
    <item>
      <title>Re: Data Merge Help</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Data-Merge-Help/m-p/262135#M51106</link>
      <description>&lt;P&gt;All dataset options need to be specified in&amp;nbsp;a single pair of parentheses:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;FinalData_2(in=b where= (rule_order &amp;lt; 997.1))&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 07 Apr 2016 17:02:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Data-Merge-Help/m-p/262135#M51106</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2016-04-07T17:02:11Z</dc:date>
    </item>
    <item>
      <title>Re: Data Merge Help</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Data-Merge-Help/m-p/262137#M51107</link>
      <description>&lt;P&gt;All of the dataset options go inside a single set of parentheses. &amp;nbsp;&lt;/P&gt;
&lt;P&gt;So if you want to filter the records coming from FINALDATA_2 you would use :&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt; FinalData_2(in=b  where= (rule_order &amp;lt; 997.1))&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 07 Apr 2016 17:03:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Data-Merge-Help/m-p/262137#M51107</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2016-04-07T17:03:57Z</dc:date>
    </item>
    <item>
      <title>Re: Data Merge Help</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Data-Merge-Help/m-p/262157#M51112</link>
      <description>&lt;P&gt;Just in case you are not aware of the pitfalls of your WHERE condition &lt;FONT face="courier new,courier"&gt;(rule_order &amp;lt; 997.1)&lt;/FONT&gt;:&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;Missing values of RULE_ORDER would satisfy this condition. Use &lt;FONT face="courier new,courier"&gt;&lt;SPAN&gt;(&lt;STRONG&gt;. &amp;lt;&lt;/STRONG&gt; rule_order &amp;lt; 997.1)&lt;/SPAN&gt;&lt;/FONT&gt;&amp;nbsp;to exclude them. (Or even safer: &lt;SPAN&gt;&lt;FONT face="courier new,courier"&gt;(&lt;STRONG&gt;.z &amp;lt;&lt;/STRONG&gt; rule_order &amp;lt; 997.1)&lt;/FONT&gt;)&lt;/SPAN&gt;&lt;/LI&gt;
&lt;LI&gt;Depending on how RULE_ORDER received its values (calculation, transfer from a database, ...), it can happen that due to certain rounding or numeric representation issues a value which should actually be equal to 997.1 is in fact stored as a slightly smaller number. (Remedy: &lt;FONT face="courier new,courier"&gt;(&lt;SPAN&gt;.z &amp;lt; &lt;/SPAN&gt;&lt;STRONG&gt;round(&lt;/STRONG&gt;rule_order&lt;STRONG&gt;, 1E-9)&amp;nbsp;&lt;/STRONG&gt;&amp;lt; 997.1)&lt;/FONT&gt;, but the rounding unit, 1E-9, might need to be adapted, depending on your data.) Please see the example below and what it writes to the log (at least on Windows systems):&lt;/LI&gt;
&lt;/OL&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data demo;
x=997.3-0.2;
y=997.1;
if x&amp;lt;997.1 then put '###### Surprised? ######';
d=y-x;
run;

data _null_;
set demo;
put x= 32.28   /  /* naive attempt to see what's in X */
    x= best32. /  /* another naive attempt */
    x= hex16.  /  /* correct way to see what's in X */
    y= hex16.  /  /* correct way to see what's in Y */
    '                 ^' /
    'Please note the difference in the last bit.' /
    d=;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 07 Apr 2016 18:05:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Data-Merge-Help/m-p/262157#M51112</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2016-04-07T18:05:42Z</dc:date>
    </item>
  </channel>
</rss>

