<?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: Two tables check all columns in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Two-tables-check-all-columns/m-p/601747#M174099</link>
    <description>&lt;P&gt;super ! Working fine&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 05 Nov 2019 18:19:52 GMT</pubDate>
    <dc:creator>mmkr</dc:creator>
    <dc:date>2019-11-05T18:19:52Z</dc:date>
    <item>
      <title>Two tables check all columns</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Two-tables-check-all-columns/m-p/601704#M174081</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Iam looking for check two tables and check all the columns and produce the reuslt&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Example :&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;DIV&gt;&lt;SPAN&gt;data table1;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;
&lt;DIV&gt;input col1 $ col2 $ col3 $ col4 $ col5 $;&lt;/DIV&gt;
&lt;DIV&gt;cards;&lt;/DIV&gt;
&lt;DIV&gt;value11 value12 value13 value14 value15&lt;/DIV&gt;
&lt;DIV&gt;value21 value22 value23 value24 value25&lt;/DIV&gt;
&lt;DIV&gt;value31 value32 value33 value34 value35&lt;/DIV&gt;
&lt;DIV&gt;value41 value42 value43 value44 value45&lt;/DIV&gt;
&lt;DIV&gt;value51 value52 value53 value54 value55&lt;/DIV&gt;
&lt;DIV&gt;;&lt;/DIV&gt;
&lt;DIV&gt;run;&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;data table2;&lt;/DIV&gt;
&lt;DIV&gt;input col1 $ col2 $ col3 $ col4 $ col5 $;&lt;/DIV&gt;
&lt;DIV&gt;cards;&lt;/DIV&gt;
&lt;DIV&gt;value11 value12 value13 value14 value15&lt;/DIV&gt;
&lt;DIV&gt;value21 value22 value23 value24 value25&lt;/DIV&gt;
&lt;DIV&gt;value31 value32 value33 value34 value35&lt;/DIV&gt;
&lt;DIV&gt;value41 value42 value00 value44 value45&lt;/DIV&gt;
&lt;DIV&gt;value51 value52 value53 value00 value55&lt;/DIV&gt;
&lt;DIV&gt;;&lt;/DIV&gt;
&lt;SPAN&gt;run;&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN&gt;result iam expecting :&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;col1 col2 col3 col4 col5 result&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN&gt;value11 value12 value13 value14 value15 All_columns_matched&lt;BR /&gt;&lt;/SPAN&gt;
&lt;DIV&gt;value21 value22 value23 value24 value25 All_columns_matched&lt;/DIV&gt;
&lt;DIV&gt;value31 value32 value33 value34 value35 All_columns_matched&lt;/DIV&gt;
&lt;DIV&gt;value41 value42 value00 value44 value45 All_columns_not_matched&lt;/DIV&gt;
&lt;SPAN&gt;value51 value52 value53 value00 value55 All_columns_not_matched&lt;/SPAN&gt;&lt;/DIV&gt;</description>
      <pubDate>Tue, 05 Nov 2019 16:46:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Two-tables-check-all-columns/m-p/601704#M174081</guid>
      <dc:creator>mmkr</dc:creator>
      <dc:date>2019-11-05T16:46:24Z</dc:date>
    </item>
    <item>
      <title>Re: Two tables check all columns</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Two-tables-check-all-columns/m-p/601709#M174083</link>
      <description>PROC COMPARE - have you tried that yet? Does it not do what you want?</description>
      <pubDate>Tue, 05 Nov 2019 17:04:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Two-tables-check-all-columns/m-p/601709#M174083</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2019-11-05T17:04:34Z</dc:date>
    </item>
    <item>
      <title>Re: Two tables check all columns</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Two-tables-check-all-columns/m-p/601713#M174085</link>
      <description>&lt;P&gt;It's doesn't giving me exact result ..it's actually showing in log result window&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I tried to put out= resulttablename but it is displaying only the differences as XX Mark&lt;/P&gt;</description>
      <pubDate>Tue, 05 Nov 2019 17:12:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Two-tables-check-all-columns/m-p/601713#M174085</guid>
      <dc:creator>mmkr</dc:creator>
      <dc:date>2019-11-05T17:12:05Z</dc:date>
    </item>
    <item>
      <title>Re: Two tables check all columns</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Two-tables-check-all-columns/m-p/601714#M174086</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/44256"&gt;@mmkr&lt;/a&gt;: What &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza&lt;/a&gt;&amp;nbsp;said. If you just want to compare record by record, proc COMPARE is your friend, for example:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data table1 ;                                                                                                                           
  input (col1-col5) ($) ;                                                                                                               
  cards ;                                                                                                                               
value11 value12 value13 value14 value15                                                                                                 
value21 value22 value23 value24 value25                                                                                                 
value31 value32 value33 value34 value35                                                                                                 
value41 value42 value43 value44 value45                                                                                                 
value51 value52 value53 value54 value55                                                                                                 
;                                                                                                                                       
run;                                                                                                                                    
                                                                                                                                  
                                                                                                                                        
data table2 ;                                                                                                                           
  input (col1-col5) ($) ;                                                                                                               
  cards ;                                                                                                                               
value11 value12 value13 value14 value15                                                                                                 
value21 value22 value23 value24 value25                                                                                                 
value31 value32 value33 value34 value35                                                                                                 
value41 value42 value00 value44 value45                                                                                                 
value51 value52 value53 value00 value55                                                                                                 
;                                                                                                                                       
run ;                                                                                                                                   
                                                                                                                                        
proc compare noprint base=table1 comp=table2 out=diff ;                                                                                 
run ;                                                                                                                                   
                                                                                                                                        
data want (drop = _:) ;                                                                                                                 
  merge table2 diff (rename=(col1-col5=_c1-_c5)) ;                                                                                      
  if findc (catx (of _c:), "X") then result = "All columns not matched" ;                                                               
  else  result = "All columns matched" ;                                                                                                
run ;                                 
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Kind regards&lt;/P&gt;
&lt;P&gt;Paul D.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 05 Nov 2019 17:13:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Two-tables-check-all-columns/m-p/601714#M174086</guid>
      <dc:creator>hashman</dc:creator>
      <dc:date>2019-11-05T17:13:51Z</dc:date>
    </item>
    <item>
      <title>Re: Two tables check all columns</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Two-tables-check-all-columns/m-p/601723#M174088</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/44256"&gt;@mmkr&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;It's doesn't giving me exact result ..it's actually showing in log result window&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I tried to put out= resulttablename but it is displaying only the differences as XX Mark&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;It's a good idea to mention things like that in your original post. In generaly, the PROC COMPARE output isn't great, but you can capture the ODS table and filter it as desired. I think&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/21262"&gt;@hashman&lt;/a&gt;&amp;nbsp;solution should work, if it doesn't I suggest that approach.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here's some instructions and explanations on how to capture output that is shown. &lt;BR /&gt;&lt;A href="https://blogs.sas.com/content/sastraining/2017/03/31/capturing-output-from-any-procedure-with-an-ods-output-statement/" target="_blank"&gt;https://blogs.sas.com/content/sastraining/2017/03/31/capturing-output-from-any-procedure-with-an-ods-output-statement/&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 05 Nov 2019 17:36:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Two-tables-check-all-columns/m-p/601723#M174088</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2019-11-05T17:36:02Z</dc:date>
    </item>
    <item>
      <title>Re: Two tables check all columns</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Two-tables-check-all-columns/m-p/601739#M174093</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/44256"&gt;@mmkr&lt;/a&gt;: It does if you do it correctly.&lt;/P&gt;
&lt;P&gt;But if you don't like proc COMPARE for some reason, in this particular case you can do it in a single step using just MERGE:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data table1 ;                                                                                                                           
  input (col1-col5) ($) ;                                                                                                               
  cards ;                                                                                                                               
value11 value12 value13 value14 value15                                                                                                 
value21 value22 value23 value24 value25                                                                                                 
value31 value32 value33 value34 value35                                                                                                 
value41 value42 value43 value44 value45                                                                                                 
value51 value52 value53 value54 value55                                                                                                 
;                                                                                                                                       
run;                                                                                                                                    
                                                                                                                                        
data table2 ;                                                                                                                           
  input (col1-col5) ($) ;                                                                                                               
  cards ;                                                                                                                               
value11 value12 value13 value14 value15                                                                                                 
value21 value22 value23 value24 value25                                                                                                 
value31 value32 value33 value34 value35                                                                                                 
value41 value42 value00 value44 value45                                                                                                 
value51 value52 value53 value00 value55                                                                                                 
;                                                                                                                                       
run ;                                                                                                                                   
                                                                                                                                        
data want (drop = _:) ;                                                                                                                 
  merge table1 table2 (rename=(col1-col5=_c1-_c5)) ;                                                                                    
  if catx (":", of col:) ne catx (":", of _c:) then result = "All columns not matched" ;                                                
  else  result = "All columns matched" ;                                                                                                
run ;                      
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;In general, it's more reliable to compare the COL and _C pairwise one by one, lest the CATX delimited should happen to be an endpoint of some value (though this snag can be circumvented). That is:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want (drop = _:) ;                                                                                                                 
  merge table1 table2 (rename=(col1-col5=_c1-_c5)) ;                                                                                    
  array col col: ;                                                                                                                      
  array _c _c: ;                                                                                                                        
  do _i_ = 1 to dim (col) until (col ne _c) ;                                                                                           
  end ;                                                                                                                                 
  if _i_ &amp;lt;= dim (col) then result = "All columns not matched" ;                                                                         
  else  result = "All columns matched" ;                                                                                                
run ;                              
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Kind regards&lt;/P&gt;
&lt;P&gt;Paul D.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 05 Nov 2019 18:04:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Two-tables-check-all-columns/m-p/601739#M174093</guid>
      <dc:creator>hashman</dc:creator>
      <dc:date>2019-11-05T18:04:37Z</dc:date>
    </item>
    <item>
      <title>Re: Two tables check all columns</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Two-tables-check-all-columns/m-p/601741#M174094</link>
      <description>&lt;P&gt;thank you so much&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It worked&lt;/P&gt;</description>
      <pubDate>Tue, 05 Nov 2019 18:08:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Two-tables-check-all-columns/m-p/601741#M174094</guid>
      <dc:creator>mmkr</dc:creator>
      <dc:date>2019-11-05T18:08:20Z</dc:date>
    </item>
    <item>
      <title>Re: Two tables check all columns</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Two-tables-check-all-columns/m-p/601744#M174096</link>
      <description>&lt;P&gt;One followup question&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;how to write all columns instead of _C&amp;nbsp; ?&lt;/P&gt;
&lt;P&gt;Because all my actual column names are not in some unique ....&lt;/P&gt;
&lt;P&gt;can i write some thing like _all_col ? is there any keyword ?&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;
&lt;PRE class=" language-sas"&gt;&lt;CODE class="  language-sas"&gt;&lt;SPAN class="token keyword"&gt;if&lt;/SPAN&gt; &lt;SPAN class="token function"&gt;findc&lt;/SPAN&gt; &lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;catx&lt;/SPAN&gt; &lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;of _c:&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;,&lt;/SPAN&gt; &lt;SPAN class="token string"&gt;"X"&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 05 Nov 2019 18:14:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Two-tables-check-all-columns/m-p/601744#M174096</guid>
      <dc:creator>mmkr</dc:creator>
      <dc:date>2019-11-05T18:14:54Z</dc:date>
    </item>
    <item>
      <title>Re: Two tables check all columns</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Two-tables-check-all-columns/m-p/601745#M174097</link>
      <description>_all_</description>
      <pubDate>Tue, 05 Nov 2019 18:17:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Two-tables-check-all-columns/m-p/601745#M174097</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2019-11-05T18:17:27Z</dc:date>
    </item>
    <item>
      <title>Re: Two tables check all columns</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Two-tables-check-all-columns/m-p/601747#M174099</link>
      <description>&lt;P&gt;super ! Working fine&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 05 Nov 2019 18:19:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Two-tables-check-all-columns/m-p/601747#M174099</guid>
      <dc:creator>mmkr</dc:creator>
      <dc:date>2019-11-05T18:19:52Z</dc:date>
    </item>
  </channel>
</rss>

