<?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: Problems with Merge Statement and IN= Option in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Problems-with-Merge-Statement-and-IN-Option/m-p/318066#M69654</link>
    <description>&lt;P&gt;Kurt's maxim #1 for effective SAS programmers: Know Your Data.&lt;/P&gt;
&lt;P&gt;Run proc contents on your input datasets and look at the variable lists.&lt;/P&gt;</description>
    <pubDate>Sat, 10 Dec 2016 07:30:10 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2016-12-10T07:30:10Z</dc:date>
    <item>
      <title>Problems with Merge Statement and IN= Option</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Problems-with-Merge-Statement-and-IN-Option/m-p/318038#M69648</link>
      <description>&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;(Sytax #1)&lt;/STRONG&gt; I merged two datasets, got no errors and the dataset looks as expected (23 variables).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;(Syntax #2)&lt;/STRONG&gt; Next I wanted to make the IN= variables permanent. I got no errors but the merged dataset is exactly the same as the previous code where # of variables=23. To test that SAS was functioning I deliberately reversed the variables on either side of the equal sign and got an error.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;(Syntax #3)&lt;/STRONG&gt; Then I decided to create a ‘Match variable’ with 3 different categories. But the merge dataset is still identical to before and the new match variable was not added to the dataset.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;SAS 9.4 recognizes if I insert an error an also if I use the 'If a' or 'If b' options. Condensed synytax&amp;nbsp;is below.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What gives?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;(SYNTAX #1)
DATA all_rates;
MERGE archived_data (in=a)
     recent_rates1 (in=b);
 by procedure_code procedure_type;
run;
NOTE: The data set WORK.ALL_RATES has 17842 observations and 23 variables.


(SYNTAX #2)
DATA all_rates ;
MERGE archived_data (in=a)
     recent_rates1 (in=b);
by procedure_code procedure_type;
    archived=a;
    recent=b;
run;
NOTE: The data set WORK.ALL_RATES has 17842 observations and 23 variables.


(SYNTAX #3)
DATA all_rates ;
MERGE archived_data (in=a)
     recent_rates1 (in=b);
by procedure_code procedure_type;
     if a and b then match='match';
     if a and not b then match='archived';
     if b and not a then match='recent';
run;
NOTE: The data set WORK.ALL_RATES has 17842 observations and 23 variables.





&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 10 Dec 2016 01:17:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Problems-with-Merge-Statement-and-IN-Option/m-p/318038#M69648</guid>
      <dc:creator>eap</dc:creator>
      <dc:date>2016-12-10T01:17:50Z</dc:date>
    </item>
    <item>
      <title>Re: Problems with Merge Statement and IN= Option</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Problems-with-Merge-Statement-and-IN-Option/m-p/318044#M69651</link>
      <description>&lt;P&gt;The only explanation for not getting additional variables is, that these variables already exist in one of your source data sets; else everything looks totally fine with your code.&lt;/P&gt;</description>
      <pubDate>Sat, 10 Dec 2016 02:36:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Problems-with-Merge-Statement-and-IN-Option/m-p/318044#M69651</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2016-12-10T02:36:47Z</dc:date>
    </item>
    <item>
      <title>Re: Problems with Merge Statement and IN= Option</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Problems-with-Merge-Statement-and-IN-Option/m-p/318066#M69654</link>
      <description>&lt;P&gt;Kurt's maxim #1 for effective SAS programmers: Know Your Data.&lt;/P&gt;
&lt;P&gt;Run proc contents on your input datasets and look at the variable lists.&lt;/P&gt;</description>
      <pubDate>Sat, 10 Dec 2016 07:30:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Problems-with-Merge-Statement-and-IN-Option/m-p/318066#M69654</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2016-12-10T07:30:10Z</dc:date>
    </item>
    <item>
      <title>Re: Problems with Merge Statement and IN= Option</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Problems-with-Merge-Statement-and-IN-Option/m-p/319106#M70007</link>
      <description>&lt;P&gt;Hey Guys,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Just wanted to give an update (albeit a little delayed....had lots of traveling). Thanks Kurt and Patrick, I had no idea what approach to take to start investigating. You both put me on a path to think differently about the data.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Well, the culpruit was two-fold. First, I did PROC CONTENTS and found that indeed one dataset had the wrong length and format for one of the sorting variables -not sure why I didn't get a warning or error. Lastly, once that was fixed I got an error about duplicates in the&amp;nbsp;BY variables. Once these were fixed everything worked fine.&lt;/P&gt;</description>
      <pubDate>Thu, 15 Dec 2016 02:52:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Problems-with-Merge-Statement-and-IN-Option/m-p/319106#M70007</guid>
      <dc:creator>eap</dc:creator>
      <dc:date>2016-12-15T02:52:54Z</dc:date>
    </item>
  </channel>
</rss>

