<?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: Data Type Error in Proc sql in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Data-Type-Error-in-Proc-sql/m-p/880083#M347719</link>
    <description>&lt;PRE&gt;ERROR: Column 5 from the first contributor of EXCEPT is not the same type as its counterpart from the second.
ERROR: Column 6 from the first contributor of EXCEPT is not the same type as its counterpart from the second.&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The mismatch in data type is in Column 5 and Column 6 in ALLDATA. Please examine those variables carefully in both data sets.&lt;/P&gt;</description>
    <pubDate>Sun, 11 Jun 2023 20:56:23 GMT</pubDate>
    <dc:creator>PaigeMiller</dc:creator>
    <dc:date>2023-06-11T20:56:23Z</dc:date>
    <item>
      <title>Data Type Error in Proc sql</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Data-Type-Error-in-Proc-sql/m-p/880082#M347718</link>
      <description>&lt;P&gt;I Have the following data sets: AllData, Death, and Live. AllData has more observations than Death and Live combined.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to have a data set of AllData excluding Death observations. I keep getting these errors when I'm using the code:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;proc sql;
create table Live as
select * from AllData
except
select * from Death
;
quit;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;WARNING: A table has been extended with null columns to perform the EXCEPT set operation.&lt;BR /&gt;ERROR: Column 5 from the first contributor of EXCEPT is not the same type as its counterpart from the second.&lt;BR /&gt;ERROR: Numeric expression requires a numeric format.&lt;BR /&gt;ERROR: Column 6 from the first contributor of EXCEPT is not the same type as its counterpart from&amp;nbsp;the second.&lt;/P&gt;&lt;P&gt;The variable causing the errors is the DOB having the Types as follows:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="mayasak_0-1686515155094.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/84879iA15C6FEA3286A0B5/image-size/medium?v=v2&amp;amp;px=400" role="button" title="mayasak_0-1686515155094.png" alt="mayasak_0-1686515155094.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="mayasak_1-1686515207740.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/84880iC620E28C22BA561D/image-size/medium?v=v2&amp;amp;px=400" role="button" title="mayasak_1-1686515207740.png" alt="mayasak_1-1686515207740.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;I'm not sure why DOB in both datasets (imported from .xlsx with a 'date' type) are imported into SAS as Num and why are they causing this issue.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;**I also used this code but it's giving AllData dataset without any death exclusions!&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;data live2;
set AllData;
if _n_ = 1
then do;
  declare hash d (dataset:"Death");
  d.definekey("Patient_Name");
  d.definedone();
end;
if d.check() ne 0;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Your help and support is greatly appreciated.&lt;/P&gt;&lt;P&gt;Thank you&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 11 Jun 2023 20:37:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Data-Type-Error-in-Proc-sql/m-p/880082#M347718</guid>
      <dc:creator>mayasak</dc:creator>
      <dc:date>2023-06-11T20:37:24Z</dc:date>
    </item>
    <item>
      <title>Re: Data Type Error in Proc sql</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Data-Type-Error-in-Proc-sql/m-p/880083#M347719</link>
      <description>&lt;PRE&gt;ERROR: Column 5 from the first contributor of EXCEPT is not the same type as its counterpart from the second.
ERROR: Column 6 from the first contributor of EXCEPT is not the same type as its counterpart from the second.&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The mismatch in data type is in Column 5 and Column 6 in ALLDATA. Please examine those variables carefully in both data sets.&lt;/P&gt;</description>
      <pubDate>Sun, 11 Jun 2023 20:56:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Data-Type-Error-in-Proc-sql/m-p/880083#M347719</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2023-06-11T20:56:23Z</dc:date>
    </item>
    <item>
      <title>Re: Data Type Error in Proc sql</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Data-Type-Error-in-Proc-sql/m-p/880085#M347720</link>
      <description>&lt;P&gt;I had this in my proc contents for both datasets. I can't find any discrepancies. As I mentioned before, DOB seems to cause the issue but I'm not sure how!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="mayasak_0-1686517555685.png" style="width: 636px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/84882i6257CFB3DFA88941/image-dimensions/636x244?v=v2" width="636" height="244" role="button" title="mayasak_0-1686517555685.png" alt="mayasak_0-1686517555685.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 11 Jun 2023 21:06:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Data-Type-Error-in-Proc-sql/m-p/880085#M347720</guid>
      <dc:creator>mayasak</dc:creator>
      <dc:date>2023-06-11T21:06:31Z</dc:date>
    </item>
    <item>
      <title>Re: Data Type Error in Proc sql</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Data-Type-Error-in-Proc-sql/m-p/880087#M347721</link>
      <description>&lt;P&gt;Please don't be so stingy with your screen captures, show us more of the output from PROC CONTENTS so we can see the relevant parts including which variable is 5 in ALLDATA and which variable is 6 in ALLDATA, and including the part of the PROC CONTENTS output that indicates which data set is which..&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;As I mentioned before, DOB seems to cause the issue but I'm not sure how!&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;No! It's column 5 and column 6, one of which may be DOB, but there's another variable we need information on as well.&lt;/P&gt;</description>
      <pubDate>Sun, 11 Jun 2023 21:21:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Data-Type-Error-in-Proc-sql/m-p/880087#M347721</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2023-06-11T21:21:02Z</dc:date>
    </item>
    <item>
      <title>Re: Data Type Error in Proc sql</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Data-Type-Error-in-Proc-sql/m-p/880095#M347723</link>
      <description>&lt;P&gt;Thank you PaigeMiller.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here's the proc contents of AllData&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="mayasak_3-1686518063108.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/84886i3FB3E42D417B9D50/image-size/medium?v=v2&amp;amp;px=400" role="button" title="mayasak_3-1686518063108.png" alt="mayasak_3-1686518063108.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="mayasak_2-1686517967978.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/84885iFA9C98293372A3C9/image-size/medium?v=v2&amp;amp;px=400" role="button" title="mayasak_2-1686517967978.png" alt="mayasak_2-1686517967978.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;And the proc contents of Death:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="mayasak_4-1686518124700.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/84887iB9332298BBA19990/image-size/medium?v=v2&amp;amp;px=400" role="button" title="mayasak_4-1686518124700.png" alt="mayasak_4-1686518124700.png" /&gt;&lt;/span&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="mayasak_5-1686518172343.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/84888iC069E128518B7220/image-size/medium?v=v2&amp;amp;px=400" role="button" title="mayasak_5-1686518172343.png" alt="mayasak_5-1686518172343.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Please let me know if I'm missing any other information.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 11 Jun 2023 21:18:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Data-Type-Error-in-Proc-sql/m-p/880095#M347723</guid>
      <dc:creator>mayasak</dc:creator>
      <dc:date>2023-06-11T21:18:02Z</dc:date>
    </item>
    <item>
      <title>Re: Data Type Error in Proc sql</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Data-Type-Error-in-Proc-sql/m-p/880098#M347726</link>
      <description>&lt;P&gt;Just be explicit about which variables you want to select. (Don't use the * shorthand).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But what is your criteria for saying there is a match?&lt;/P&gt;
&lt;P&gt;Do you only need to have them match on SSN?&lt;/P&gt;
&lt;P&gt;Or perhaps on NAME and DOB?&lt;/P&gt;</description>
      <pubDate>Sun, 11 Jun 2023 21:59:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Data-Type-Error-in-Proc-sql/m-p/880098#M347726</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2023-06-11T21:59:00Z</dc:date>
    </item>
    <item>
      <title>Re: Data Type Error in Proc sql</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Data-Type-Error-in-Proc-sql/m-p/880100#M347728</link>
      <description>&lt;P&gt;Hi Tom,&lt;/P&gt;&lt;P&gt;Thank you for the response.&lt;/P&gt;&lt;P&gt;For the second code, I tried it because I had the errors in the first code, I was trying to match on Patient_Name only.&lt;/P&gt;</description>
      <pubDate>Sun, 11 Jun 2023 22:38:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Data-Type-Error-in-Proc-sql/m-p/880100#M347728</guid>
      <dc:creator>mayasak</dc:creator>
      <dc:date>2023-06-11T22:38:41Z</dc:date>
    </item>
    <item>
      <title>Re: Data Type Error in Proc sql</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Data-Type-Error-in-Proc-sql/m-p/880103#M347731</link>
      <description>&lt;P&gt;That is simple to do:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
create table Live as
  select * from AllData
  where Patient_Name not in (select Patient_Name from Death)
;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;But depending on how clear (or really how consistent) your data is might not do exactly what you want.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;At a minimum you might want to ignore the case of the letters in the Patient_Name variable.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;where upcase(Patient_Name) not in (select upcase(Patient_Name) from Death)&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 11 Jun 2023 22:46:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Data-Type-Error-in-Proc-sql/m-p/880103#M347731</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2023-06-11T22:46:45Z</dc:date>
    </item>
    <item>
      <title>Re: Data Type Error in Proc sql</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Data-Type-Error-in-Proc-sql/m-p/880108#M347736</link>
      <description>Thank you Tom</description>
      <pubDate>Sun, 11 Jun 2023 23:47:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Data-Type-Error-in-Proc-sql/m-p/880108#M347736</guid>
      <dc:creator>mayasak</dc:creator>
      <dc:date>2023-06-11T23:47:51Z</dc:date>
    </item>
  </channel>
</rss>

