<?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 COMPARE - How to output unequal variable names not values in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/PROC-COMPARE-How-to-output-unequal-variable-names-not-values/m-p/781289#M249011</link>
    <description>&lt;P&gt;Hi Folks,&lt;/P&gt;&lt;P&gt;In PROC COMPARE is there any way to output (to a table) only the names of the variables where a value mismatch has been found between the two datasets?&lt;/P&gt;&lt;P&gt;So, not the variable values, just the name of the variable.&lt;/P&gt;&lt;P&gt;I have tried using OUT=table OUTNOEQUAL OUTDIF OUTBASE OUTCOMP but this outputs all the variables which have been compared, and I only want to see the names of variables which have a value mismatch.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For example, I am comparing two datasets with over 2500 variables, say 20 of these variables have unequal values, I want to extract only these variable names for use in a macro which I will create separate tables with obs pulled from both datasets to show the value differences.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I know I could use PRINTALL to display this in the log but I do not have enough programming experience to know how to interrogate the log to extract this information.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is this possible? Or if I used all the OUT options above could anyone help me with the code to play find the "X" to extract the variable NAME where _TYPE_ = "DIF" from the output dataset?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I hope I have managed to make this question clear.&amp;nbsp; Many thanks for taking the time to read it!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 19 Nov 2021 15:56:33 GMT</pubDate>
    <dc:creator>NickC1</dc:creator>
    <dc:date>2021-11-19T15:56:33Z</dc:date>
    <item>
      <title>PROC COMPARE - How to output unequal variable names not values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-COMPARE-How-to-output-unequal-variable-names-not-values/m-p/781289#M249011</link>
      <description>&lt;P&gt;Hi Folks,&lt;/P&gt;&lt;P&gt;In PROC COMPARE is there any way to output (to a table) only the names of the variables where a value mismatch has been found between the two datasets?&lt;/P&gt;&lt;P&gt;So, not the variable values, just the name of the variable.&lt;/P&gt;&lt;P&gt;I have tried using OUT=table OUTNOEQUAL OUTDIF OUTBASE OUTCOMP but this outputs all the variables which have been compared, and I only want to see the names of variables which have a value mismatch.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For example, I am comparing two datasets with over 2500 variables, say 20 of these variables have unequal values, I want to extract only these variable names for use in a macro which I will create separate tables with obs pulled from both datasets to show the value differences.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I know I could use PRINTALL to display this in the log but I do not have enough programming experience to know how to interrogate the log to extract this information.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is this possible? Or if I used all the OUT options above could anyone help me with the code to play find the "X" to extract the variable NAME where _TYPE_ = "DIF" from the output dataset?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I hope I have managed to make this question clear.&amp;nbsp; Many thanks for taking the time to read it!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 19 Nov 2021 15:56:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-COMPARE-How-to-output-unequal-variable-names-not-values/m-p/781289#M249011</guid>
      <dc:creator>NickC1</dc:creator>
      <dc:date>2021-11-19T15:56:33Z</dc:date>
    </item>
    <item>
      <title>Re: PROC COMPARE - How to output unequal variable names not values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-COMPARE-How-to-output-unequal-variable-names-not-values/m-p/781295#M249012</link>
      <description>&lt;P&gt;I have read your post quickly and diagonally, but this may be what you want :&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data work.a;
 set sashelp.class;
 if _N_=10 then height=27000;
run;

ODS TRACE OFF;
ODS OUTPUT CompareSummary=work.CompareSummary;
proc compare base=sashelp.class compare=work.a /* printall */;
   title 'Comparing Two Data Sets: Full Report';
run;

/* then look in the data set work.CompareSummary */

/* end of program */&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Koen&lt;/P&gt;</description>
      <pubDate>Fri, 19 Nov 2021 16:13:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-COMPARE-How-to-output-unequal-variable-names-not-values/m-p/781295#M249012</guid>
      <dc:creator>sbxkoenk</dc:creator>
      <dc:date>2021-11-19T16:13:47Z</dc:date>
    </item>
    <item>
      <title>Re: PROC COMPARE - How to output unequal variable names not values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-COMPARE-How-to-output-unequal-variable-names-not-values/m-p/781303#M249015</link>
      <description>&lt;P&gt;Something like this perhaps.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data class;
   set sashelp.class;
   if ranuni(3) lt .5 then do;
      weight = weight+1;
      height = height-1;
      sex    = lowcase(sex);
      end;

   run;
ods select none;
ods trace on;
proc compare novalues base=sashelp.class compare=class;
   ods output CompareSummary=CompareSummary;
   run;
ods trace off;
ods select all;
proc print;
   run;

data vars;
   set CompareSummary;
   retain keep 0;
   if type eq 'h' and strip(batch) eq 'Variables with Unequal Values' then keep=1;
   if keep;
   if type eq 'd' and not missing(batch);
   length var $32;
   var = scan(batch,1,' ');
   run;
proc print;
   run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Capture.PNG" style="width: 275px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/65913i950BA04C0681723E/image-size/large?v=v2&amp;amp;px=999" role="button" title="Capture.PNG" alt="Capture.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 19 Nov 2021 16:33:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-COMPARE-How-to-output-unequal-variable-names-not-values/m-p/781303#M249015</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2021-11-19T16:33:47Z</dc:date>
    </item>
    <item>
      <title>Re: PROC COMPARE - How to output unequal variable names not values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-COMPARE-How-to-output-unequal-variable-names-not-values/m-p/781313#M249018</link>
      <description>&lt;P&gt;Brilliant, thank you! That is exactly what I need, very much appreciate the quick responses.&lt;/P&gt;</description>
      <pubDate>Fri, 19 Nov 2021 16:46:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-COMPARE-How-to-output-unequal-variable-names-not-values/m-p/781313#M249018</guid>
      <dc:creator>NickC1</dc:creator>
      <dc:date>2021-11-19T16:46:52Z</dc:date>
    </item>
    <item>
      <title>Re: PROC COMPARE - How to output unequal variable names not values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-COMPARE-How-to-output-unequal-variable-names-not-values/m-p/781329#M249020</link>
      <description>&lt;P&gt;This is another way that may be useful.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data class;
   set sashelp.class;
   if ranuni(3) lt .5 then do;
      weight = weight+1;
      height = height-1;
      sex    = lowcase(sex);
      end;
    run;
filename lst temp;
ods listing file=lst;
proc compare novalues brief base=sashelp.class compare=class;
   run;
ods listing close;

data vars;
   infile lst col=col;
   input @'NOTE: Values of the following' varnum @;
   input @'variables compare unequal:' @;
   do i = 1 to varnum;
      input variable:$32. @;
      output;
      end;
   stop;
   run;
proc print;
   run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 19 Nov 2021 17:17:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-COMPARE-How-to-output-unequal-variable-names-not-values/m-p/781329#M249020</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2021-11-19T17:17:18Z</dc:date>
    </item>
  </channel>
</rss>

