<?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 Proc comparison with different data types. in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Proc-comparison-with-different-data-types/m-p/874653#M345594</link>
    <description>Hi All,&lt;BR /&gt;Can anyone please suggest me what to do if the data types is different in both the files while doing proc comparison.&lt;BR /&gt;&lt;BR /&gt;Code:&lt;BR /&gt;Proc compare base=file1 compare=file2;&lt;BR /&gt;ID userid useritemid;&lt;BR /&gt;Run;&lt;BR /&gt;&lt;BR /&gt;In the above example&lt;BR /&gt;File1 - userid as character&lt;BR /&gt;File2 - userid as numeric&lt;BR /&gt;&lt;BR /&gt;File1-useritemid as character&lt;BR /&gt;File2-useritemid as numeric&lt;BR /&gt;&lt;BR /&gt;Error message:the following 2 ID variables have inconsistent types in the base and comparison data sets;userid useritemid.&lt;BR /&gt;&lt;BR /&gt;Can anyone suggest what to do in this case</description>
    <pubDate>Tue, 09 May 2023 13:18:22 GMT</pubDate>
    <dc:creator>Akshaya_1397</dc:creator>
    <dc:date>2023-05-09T13:18:22Z</dc:date>
    <item>
      <title>Proc comparison with different data types.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-comparison-with-different-data-types/m-p/874653#M345594</link>
      <description>Hi All,&lt;BR /&gt;Can anyone please suggest me what to do if the data types is different in both the files while doing proc comparison.&lt;BR /&gt;&lt;BR /&gt;Code:&lt;BR /&gt;Proc compare base=file1 compare=file2;&lt;BR /&gt;ID userid useritemid;&lt;BR /&gt;Run;&lt;BR /&gt;&lt;BR /&gt;In the above example&lt;BR /&gt;File1 - userid as character&lt;BR /&gt;File2 - userid as numeric&lt;BR /&gt;&lt;BR /&gt;File1-useritemid as character&lt;BR /&gt;File2-useritemid as numeric&lt;BR /&gt;&lt;BR /&gt;Error message:the following 2 ID variables have inconsistent types in the base and comparison data sets;userid useritemid.&lt;BR /&gt;&lt;BR /&gt;Can anyone suggest what to do in this case</description>
      <pubDate>Tue, 09 May 2023 13:18:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-comparison-with-different-data-types/m-p/874653#M345594</guid>
      <dc:creator>Akshaya_1397</dc:creator>
      <dc:date>2023-05-09T13:18:22Z</dc:date>
    </item>
    <item>
      <title>Re: Proc comparison with different data types.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-comparison-with-different-data-types/m-p/874666#M345597</link>
      <description>&lt;P&gt;As you have seen, the PROC step won't execute under these conditions.&amp;nbsp; You would have to convert one or the other data set.&amp;nbsp; However, you don't need to create a new data set.&amp;nbsp; Instead, create a view and feed the view into PROC COMPARE.&amp;nbsp; One possibility (converting from character to numeric in the first file):&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data file1_numeric / view=file1_numeric;
   set file1;
   temp_id = input(userid, 8.);
   temp_item = input(useritemid, 8.);
   drop userid useritemid;
   rename temp_id = userid;
   rename temp_item = useritemid;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Then run your PROC COMPARE with file1_numeric and file2.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Of course the best solution would be to user the same structure in both of your data sets originally.&amp;nbsp; And the second best solution would be to permanently convert your current data sets so they use the same structure.&amp;nbsp; But if you are looking for a third best solution, this would be a way to approach it.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You may run into other problems.&amp;nbsp; For example, perhaps some of the IDs were made character because they couldn't be stored as numeric.&amp;nbsp; Perhaps they contain letters.&amp;nbsp; You would have to examine the log for cases where the INPUT function gives you a message about invalid data.&amp;nbsp; When the INPUT function uses the 8. informat, it assumes that you have nothing longer than 8 digits.&amp;nbsp; If you have longer values, using a longer length in the INPUT function.&lt;/P&gt;</description>
      <pubDate>Tue, 09 May 2023 14:09:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-comparison-with-different-data-types/m-p/874666#M345597</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2023-05-09T14:09:20Z</dc:date>
    </item>
    <item>
      <title>Re: Proc comparison with different data types.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-comparison-with-different-data-types/m-p/874673#M345602</link>
      <description>&lt;P&gt;Go back to the process that created a userid as numeric. This process is faulty and needs to be fixed.&lt;/P&gt;</description>
      <pubDate>Tue, 09 May 2023 14:52:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-comparison-with-different-data-types/m-p/874673#M345602</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2023-05-09T14:52:15Z</dc:date>
    </item>
    <item>
      <title>Re: Proc comparison with different data types.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-comparison-with-different-data-types/m-p/875422#M345884</link>
      <description>Thankyou for the detailed explanation.&lt;BR /&gt;It worked for me thanks.</description>
      <pubDate>Fri, 12 May 2023 11:09:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-comparison-with-different-data-types/m-p/875422#M345884</guid>
      <dc:creator>Akshaya_1397</dc:creator>
      <dc:date>2023-05-12T11:09:33Z</dc:date>
    </item>
  </channel>
</rss>

