title: How can I avoid this error in SAS?
body: <p>When trying to merge datasets in SAS I continuously get the following error for a number of variables:</p>
  
  <blockquote>
    <p>Column 115 from the first contributor of OUTER UNION is not the same type as its
           counterpart from the second</p>
  </blockquote>
  
  <p>I've been able to get around this error usually by doing the following:</p>
  
  <ol>
  <li><p>Changing one of the variables to the same "type" of the other. For example, changing variable A to a character type from a numeric type so that it matches the variable in the other dataset thereby allowing the merge to happen.</p></li>
  <li><p>Importing the datasets that I am trying to merge together as CSV files and then adding the "guessing rows" option in the proc import step. For example:</p></li>
  </ol>
  
  <hr />
  
  <pre><code>proc import datafile='xxxxx'
      out=fadados
      dbms=csv replace;
      getnames=yes;
      guessingrows=200;
      run;
  </code></pre>
  
  <p>However, sometimes in spite of importing my files as CSVs and using "guessingrows" I still get the above error and sometimes there are so many that it is VERY time consuming and not feasible to actually convert all variables to the same "type" so that they match between datasets.</p>
  
  <p>Can anyone advise me on how I can easily AVOID this error? Is there another way that people get around this? I get this error so often that I am tired of having to convert every single variable. There must be another way!</p>
  
  <p>******UPDATE*****
  Here is an example that everyone is asking for:</p>
  
  <pre><code>  proc sql;
         title 'MED REC COMBINED';
         create table combined_bn_hw as
            select * from bndados
            outer union corr
            select * from hwdados;
      quit;
  
  And here is the output I get in the log:
  
  21019  proc sql;
  21020     title 'MED REC COMBINED';
  21021     create table combined_bn_hw as
  21022        select * from bndados
  21023        outer union corr
  21024        select * from hwdados;
  ERROR: Column 115 from the first contributor of OUTER UNION is not the same type as its
         counterpart from the second.
  ERROR: Column 120 from the first contributor of OUTER UNION is not the same type as its
         counterpart from the second.
  ERROR: Column 173 from the first contributor of OUTER UNION is not the same type as its
         counterpart from the second.
  ERROR: Numeric expression requires a numeric format.
  ERROR: Column 181 from the first contributor of OUTER UNION is not the same type as its
         counterpart from the second.
  ERROR: Column 185 from the first contributor of OUTER UNION is not the same type as its
         counterpart from the second.
  ERROR: Column 186 from the first contributor of OUTER UNION is not the same type as its
         counterpart from the second.
  21025  quit;
  NOTE: The SAS System stopped processing this step because of errors.
  NOTE: PROCEDURE SQL used (Total process time):
        real time           0.01 seconds
        cpu time            0.00 seconds
  </code></pre>