<?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: NDIF for all vars (not just numeric vars) using proc compare in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/NDIF-for-all-vars-not-just-numeric-vars-using-proc-compare/m-p/689635#M209667</link>
    <description>&lt;P&gt;Thanks for this. I have over 100 variables so this may not be very practical.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 07 Oct 2020 17:22:09 GMT</pubDate>
    <dc:creator>K_S</dc:creator>
    <dc:date>2020-10-07T17:22:09Z</dc:date>
    <item>
      <title>NDIF for all vars (not just numeric vars) using proc compare</title>
      <link>https://communities.sas.com/t5/SAS-Programming/NDIF-for-all-vars-not-just-numeric-vars-using-proc-compare/m-p/689572#M209645</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;I am comparing variables within the same dataset. I am trying to get an output dataset that lists the variables being compared and the number of differences counted.&lt;/P&gt;&lt;P&gt;This is what I currently have in my syntax, and the problem is that it outputs the ndif for numeric vars only. I would like the NDIF for all vars and not just the numeric ones.&lt;/P&gt;&lt;P&gt;proc compare base=mydata maxprint=0 outstats=summary;&lt;/P&gt;&lt;P&gt;var x; with x_old;&lt;/P&gt;&lt;P&gt;var Y; with Y_old;&lt;/P&gt;&lt;P&gt;.......&lt;/P&gt;&lt;P&gt;....;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;data Ndiffs;&lt;BR /&gt;set summary;&lt;BR /&gt;if _TYPE_ not in ("NDIF") then delete;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 07 Oct 2020 14:55:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/NDIF-for-all-vars-not-just-numeric-vars-using-proc-compare/m-p/689572#M209645</guid>
      <dc:creator>K_S</dc:creator>
      <dc:date>2020-10-07T14:55:43Z</dc:date>
    </item>
    <item>
      <title>Re: NDIF for all vars (not just numeric vars) using proc compare</title>
      <link>https://communities.sas.com/t5/SAS-Programming/NDIF-for-all-vars-not-just-numeric-vars-using-proc-compare/m-p/689578#M209648</link>
      <description>&lt;P&gt;I can get an NDIF for character variables.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;By any chance are you only getting output for the varaiable in the LAST VAR and WITH statement? I&lt;/P&gt;
&lt;P&gt;I think Proc Compare really only wants to see one one VAR and one With statement.&lt;/P&gt;</description>
      <pubDate>Wed, 07 Oct 2020 15:09:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/NDIF-for-all-vars-not-just-numeric-vars-using-proc-compare/m-p/689578#M209648</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2020-10-07T15:09:38Z</dc:date>
    </item>
    <item>
      <title>Re: NDIF for all vars (not just numeric vars) using proc compare</title>
      <link>https://communities.sas.com/t5/SAS-Programming/NDIF-for-all-vars-not-just-numeric-vars-using-proc-compare/m-p/689580#M209649</link>
      <description>&lt;P&gt;I get results in the results tab for all. But if I do an outstats dataset, then I only get outstats for the numerics.&lt;/P&gt;</description>
      <pubDate>Wed, 07 Oct 2020 15:14:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/NDIF-for-all-vars-not-just-numeric-vars-using-proc-compare/m-p/689580#M209649</guid>
      <dc:creator>K_S</dc:creator>
      <dc:date>2020-10-07T15:14:56Z</dc:date>
    </item>
    <item>
      <title>Re: NDIF for all vars (not just numeric vars) using proc compare</title>
      <link>https://communities.sas.com/t5/SAS-Programming/NDIF-for-all-vars-not-just-numeric-vars-using-proc-compare/m-p/689619#M209664</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/127053"&gt;@K_S&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I get results in the results tab for all. But if I do an outstats dataset, then I only get outstats for the numerics.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;From the documentation:&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;DIV class="xis-refProc"&gt;
&lt;DIV class="xis-procResults"&gt;
&lt;DIV id="n144xxvag5fdvsn1jzei8sva84kb" class="xis-subTopic"&gt;
&lt;DIV id="p1pkkrcp99fvr9n1m9mmc7ac5p2a" class="xis-topicContent"&gt;
&lt;DIV id="p016wk5qdq10skn1f26yhla2grme" class="xis-paragraph"&gt;When you use the OUTSTATS= option, PROC COMPARE calculates the same summary statistics as the ALLSTATS option for each pair of &lt;FONT color="#0000FF"&gt;&lt;STRONG&gt;numeric variables&lt;/STRONG&gt;&lt;/FONT&gt; that are compared.&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;I added the emphasis.&lt;/P&gt;
&lt;P&gt;Proc compare is old and likely not getting many features added. So another approach is going to be needed.&lt;/P&gt;
&lt;P&gt;Maybe something along these lines:&lt;/P&gt;
&lt;PRE&gt;data need;
   set mydata;
   Array new x y z;
   Array old x_old y_old z_old;
   array dif difx dify difz ;
   do i = 1 to dim(new);
      dif[i]= (new[i] ne old[i]);
   end;
   drop i;
run;

proc means data=need sum maxdec=0;
   var dif:;
run;&lt;/PRE&gt;
&lt;P&gt;The test dif[i]= (new[i] ne old[i]); will create 1/0 coded output with 1 meaning different.&lt;/P&gt;
&lt;P&gt;The use proc means (or summary) to sum the differences. You could create an output data set or use a report procedure to create human readable summaries.&lt;/P&gt;</description>
      <pubDate>Wed, 07 Oct 2020 18:22:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/NDIF-for-all-vars-not-just-numeric-vars-using-proc-compare/m-p/689619#M209664</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2020-10-07T18:22:35Z</dc:date>
    </item>
    <item>
      <title>Re: NDIF for all vars (not just numeric vars) using proc compare</title>
      <link>https://communities.sas.com/t5/SAS-Programming/NDIF-for-all-vars-not-just-numeric-vars-using-proc-compare/m-p/689635#M209667</link>
      <description>&lt;P&gt;Thanks for this. I have over 100 variables so this may not be very practical.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 07 Oct 2020 17:22:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/NDIF-for-all-vars-not-just-numeric-vars-using-proc-compare/m-p/689635#M209667</guid>
      <dc:creator>K_S</dc:creator>
      <dc:date>2020-10-07T17:22:09Z</dc:date>
    </item>
    <item>
      <title>Re: NDIF for all vars (not just numeric vars) using proc compare</title>
      <link>https://communities.sas.com/t5/SAS-Programming/NDIF-for-all-vars-not-just-numeric-vars-using-proc-compare/m-p/689662#M209674</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/127053"&gt;@K_S&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Thanks for this. I have over 100 variables so this may not be very practical.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;The data step ARRAY function will accept variable lists.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So if the variables you want are adjacent, i.e. have sequential column numbers when reported in Proc Contents you can use a list like:&lt;/P&gt;
&lt;P&gt;array old&amp;nbsp; var1 -- abc;&amp;nbsp; The two - indicate the adjacency.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Or if you name variables with sequential numbers as a suffix:&lt;/P&gt;
&lt;P&gt;array old x1 - x25&amp;nbsp; ; would use X1, x2, x3 ... x25.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Or if not all but most have suffixes you can mix a list and explicit names:&lt;/P&gt;
&lt;P&gt;array old x&amp;nbsp; x2-x15 x27 z1-z12; or such.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Or if all of a group of variable names start with the same character(s) you can use the : list builder.&lt;/P&gt;
&lt;P&gt;Array old stem_: ; would use all variables that start with the characters stem_.&lt;/P&gt;
&lt;P&gt;However since this needs two variables that align between the source arrays of new and old then you need to make sure they are working.&lt;/P&gt;
&lt;P&gt;The output dif array could be defined as : array dif {50}; or however many &lt;STRONG&gt;pairs&lt;/STRONG&gt; are involved. But you need to keep track of which pair is which. Which could actually be done with the VNAME function to extract the names of variables compared:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data need;
   set mydata;
   Array new x y z;
   Array old x_old y_old z_old;
   length compared $ 65;
   do i = 1 to dim(new);
      dif= (new[i] ne old[i]);
      compared = catx(' ',vname(new[i]),vname(old[i]));
      output;
   end;
   keep compared dif;
run;

proc means data=need sum maxdec=0 nway;
   class compared;
   var dif:;
run;&lt;/PRE&gt;
&lt;P&gt;The nway isn't needed for results output but likely would if creating an output data set.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But I don't see where this is any worse than listing 100 variables on Var and With statments in Proc Compare.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 07 Oct 2020 18:23:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/NDIF-for-all-vars-not-just-numeric-vars-using-proc-compare/m-p/689662#M209674</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2020-10-07T18:23:48Z</dc:date>
    </item>
    <item>
      <title>Re: NDIF for all vars (not just numeric vars) using proc compare</title>
      <link>https://communities.sas.com/t5/SAS-Programming/NDIF-for-all-vars-not-just-numeric-vars-using-proc-compare/m-p/689761#M209698</link>
      <description>&lt;P&gt;Thank you so much for the time you invested into this. Made my day!&lt;/P&gt;</description>
      <pubDate>Wed, 07 Oct 2020 22:27:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/NDIF-for-all-vars-not-just-numeric-vars-using-proc-compare/m-p/689761#M209698</guid>
      <dc:creator>K_S</dc:creator>
      <dc:date>2020-10-07T22:27:36Z</dc:date>
    </item>
  </channel>
</rss>

