<?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: proc compare write only the variable names with difference in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/proc-compare-write-only-the-variable-names-with-difference/m-p/796268#M255498</link>
    <description>&lt;P&gt;Oh, I LIKE that &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt; Very nice.&lt;/P&gt;</description>
    <pubDate>Tue, 15 Feb 2022 13:35:17 GMT</pubDate>
    <dc:creator>SASJedi</dc:creator>
    <dc:date>2022-02-15T13:35:17Z</dc:date>
    <item>
      <title>proc compare write only the variable names with difference</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-compare-write-only-the-variable-names-with-difference/m-p/796256#M255493</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In proc compare, is there a way to copy ONLY the variables names with difference in values between two tables.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks,&lt;/P&gt;
&lt;P&gt;Mushy&lt;/P&gt;</description>
      <pubDate>Tue, 15 Feb 2022 12:28:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-compare-write-only-the-variable-names-with-difference/m-p/796256#M255493</guid>
      <dc:creator>Mushy</dc:creator>
      <dc:date>2022-02-15T12:28:46Z</dc:date>
    </item>
    <item>
      <title>Re: proc compare write only the variable names with difference</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-compare-write-only-the-variable-names-with-difference/m-p/796262#M255494</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;That question is not clear to me.&lt;/P&gt;
&lt;P&gt;What do you mean with "COPY"?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This is how I use PROC COMPARE :&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/* example usage of PROC COMPARE */
proc compare base=emp95_byidnum compare=emp96_byidnum
             out=result outnoequal outbase outcomp outdif
             outstats=diffstat noprint;
   id idnum;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Thanks,&lt;/P&gt;
&lt;P&gt;Koen&lt;/P&gt;</description>
      <pubDate>Tue, 15 Feb 2022 13:15:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-compare-write-only-the-variable-names-with-difference/m-p/796262#M255494</guid>
      <dc:creator>sbxkoenk</dc:creator>
      <dc:date>2022-02-15T13:15:46Z</dc:date>
    </item>
    <item>
      <title>Re: proc compare write only the variable names with difference</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-compare-write-only-the-variable-names-with-difference/m-p/796265#M255496</link>
      <description>&lt;P&gt;This will write only the variables with differences to the OUTSTATS= dataset:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data cl1;
set sashelp.class;
run;

data cl2;
set sashelp.class;
if name = "John" then age = 13;
run;

proc compare
  data=cl1
  compare=cl2
  noprint
  outstats=stat (where=(_type_ = "NDIF" and (_base_ ne 0)))
;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 15 Feb 2022 13:33:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-compare-write-only-the-variable-names-with-difference/m-p/796265#M255496</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2022-02-15T13:33:44Z</dc:date>
    </item>
    <item>
      <title>Re: proc compare write only the variable names with difference</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-compare-write-only-the-variable-names-with-difference/m-p/796268#M255498</link>
      <description>&lt;P&gt;Oh, I LIKE that &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt; Very nice.&lt;/P&gt;</description>
      <pubDate>Tue, 15 Feb 2022 13:35:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-compare-write-only-the-variable-names-with-difference/m-p/796268#M255498</guid>
      <dc:creator>SASJedi</dc:creator>
      <dc:date>2022-02-15T13:35:17Z</dc:date>
    </item>
    <item>
      <title>Re: proc compare write only the variable names with difference</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-compare-write-only-the-variable-names-with-difference/m-p/796269#M255499</link>
      <description>&lt;P&gt;TBH, this is one of the questions that I deal with in Maxim 13 (see the Talmud quote). The OP's question made me play around with PROC COMPARE to find out how variables with differences show up in the output datasets.&lt;/P&gt;
&lt;P&gt;My first try was at using the OUT= dataset, TRANSPOSE the numerics with non-missing values, and sort that with NODUPKEY, but then I thought of the statistics, and - lo and behold! - there's NDIF. Then it was just a simple WHERE=.&lt;/P&gt;</description>
      <pubDate>Tue, 15 Feb 2022 13:42:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-compare-write-only-the-variable-names-with-difference/m-p/796269#M255499</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2022-02-15T13:42:03Z</dc:date>
    </item>
    <item>
      <title>Re: proc compare write only the variable names with difference</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-compare-write-only-the-variable-names-with-difference/m-p/796283#M255503</link>
      <description>&lt;P&gt;This is nice.&amp;nbsp; If there's any spare development time at SAS for PROC COMPARE, would love to see it made more ODS compliant, i.e. ability to use the ODS OUTPUT statement to get usable datasets out of PROC COMPARE.&lt;/P&gt;</description>
      <pubDate>Tue, 15 Feb 2022 14:29:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-compare-write-only-the-variable-names-with-difference/m-p/796283#M255503</guid>
      <dc:creator>Quentin</dc:creator>
      <dc:date>2022-02-15T14:29:28Z</dc:date>
    </item>
    <item>
      <title>Re: proc compare write only the variable names with difference</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-compare-write-only-the-variable-names-with-difference/m-p/796284#M255504</link>
      <description>&lt;P&gt;Hello Kurt,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Why does the "stat" table does not contain all variables in sashelp.class? It displays stat only for age,height and weight?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc compare&lt;BR /&gt;data=cl1&lt;BR /&gt;compare=cl2&lt;BR /&gt;noprint&lt;BR /&gt;outstats=stat&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks,&lt;/P&gt;
&lt;P&gt;Mushy&lt;/P&gt;</description>
      <pubDate>Tue, 15 Feb 2022 14:35:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-compare-write-only-the-variable-names-with-difference/m-p/796284#M255504</guid>
      <dc:creator>Mushy</dc:creator>
      <dc:date>2022-02-15T14:35:35Z</dc:date>
    </item>
    <item>
      <title>Re: proc compare write only the variable names with difference</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-compare-write-only-the-variable-names-with-difference/m-p/796314#M255511</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/393424"&gt;@Mushy&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hello Kurt,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Why does the "stat" table does not contain all variables in sashelp.class? It displays stat only for age,height and weight?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc compare&lt;BR /&gt;data=cl1&lt;BR /&gt;compare=cl2&lt;BR /&gt;noprint&lt;BR /&gt;outstats=stat&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks,&lt;/P&gt;
&lt;P&gt;Mushy&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;When you look at the output data set a key indicator the _type_ column. Note what it contains: N, Mean, Max, Min, STD and a few other values. These statistics other than N would be meaningless for character variables. What would the "mean" of the Name variable look like? Or the standard deviation? These stats are only calculated for numeric values to have meaning.&lt;/P&gt;</description>
      <pubDate>Tue, 15 Feb 2022 16:14:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-compare-write-only-the-variable-names-with-difference/m-p/796314#M255511</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2022-02-15T16:14:17Z</dc:date>
    </item>
    <item>
      <title>Re: proc compare write only the variable names with difference</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-compare-write-only-the-variable-names-with-difference/m-p/796319#M255515</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/393424"&gt;@Mushy&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hello Kurt,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Why does the "stat" table does not contain all variables in sashelp.class? It displays stat only for age,height and weight?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc compare&lt;BR /&gt;data=cl1&lt;BR /&gt;compare=cl2&lt;BR /&gt;noprint&lt;BR /&gt;outstats=stat&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks,&lt;/P&gt;
&lt;P&gt;Mushy&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;That is because the STAT= output datasets contains statistics that can only be applied to numeric values, so character variables do not appear there. If you run the compare without NOPRINT, you will see that the NAME and SEX variables are also compared:&lt;/P&gt;
&lt;PRE&gt;Anzahl der verglichenen Variablen, bei denen alle Werte gleich sind: 4.                                 
Anzahl der verglichenen Variablen, bei denen einige Werte ungleich sind: 1.                             &lt;/PRE&gt;
&lt;P&gt;(German output because of my locale, but you can see all 5 variables have been processed)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you need to find character variables also, then you need to go the more complicated way by using an OUT= dataset and processing that.&lt;/P&gt;</description>
      <pubDate>Tue, 15 Feb 2022 16:23:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-compare-write-only-the-variable-names-with-difference/m-p/796319#M255515</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2022-02-15T16:23:04Z</dc:date>
    </item>
    <item>
      <title>Re: proc compare write only the variable names with difference</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-compare-write-only-the-variable-names-with-difference/m-p/796476#M255586</link>
      <description>&lt;P&gt;Hello Kurt,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Do you already have a code/method to get to know all the variables with differences with out= irrespective of the type? I looked into it and seems to be a bit complicated&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 16 Feb 2022 08:12:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-compare-write-only-the-variable-names-with-difference/m-p/796476#M255586</guid>
      <dc:creator>Mushy</dc:creator>
      <dc:date>2022-02-16T08:12:47Z</dc:date>
    </item>
    <item>
      <title>Re: proc compare write only the variable names with difference</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-compare-write-only-the-variable-names-with-difference/m-p/796481#M255590</link>
      <description>&lt;P&gt;It is more complicated, but it's doable:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data cl1;
set sashelp.class;
run;

data cl2;
set sashelp.class;
if name = "John" then age = 13;
if name = "Jane" then sex = "M";
run;

proc compare
  data=cl1
  compare=cl2
  noprint
  out=comp
  outnoequal
  outstats=stat (where=(_type_ = "NDIF" and (_base_ ne 0)))
;
run;

proc transpose
  data=comp (drop=_type_)
  out=long1 (where=(_name_ ne "_OBS_" and not missing(col1)))
;
by _obs_;
var _numeric_;
run;

proc transpose
  data=comp (drop=_type_)
  out=long2 (where=(_name_ ne "_OBS_" and compress(col1,".") &amp;gt; " "))
;
by _obs_;
var _character_;
run;

proc sql;
create table want as
  select distinct _name_
  from long1
  union
  select distinct _name_
  from long2
;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I needed two transposes so that the exclusion conditions don't interfere with the other data type.&lt;/P&gt;</description>
      <pubDate>Wed, 16 Feb 2022 08:46:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-compare-write-only-the-variable-names-with-difference/m-p/796481#M255590</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2022-02-16T08:46:10Z</dc:date>
    </item>
    <item>
      <title>Re: proc compare write only the variable names with difference</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-compare-write-only-the-variable-names-with-difference/m-p/796488#M255595</link>
      <description>&lt;P&gt;Hi Kurt, Super Thanks!&lt;/P&gt;</description>
      <pubDate>Wed, 16 Feb 2022 08:58:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-compare-write-only-the-variable-names-with-difference/m-p/796488#M255595</guid>
      <dc:creator>Mushy</dc:creator>
      <dc:date>2022-02-16T08:58:50Z</dc:date>
    </item>
    <item>
      <title>Re: proc compare write only the variable names with difference</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-compare-write-only-the-variable-names-with-difference/m-p/796653#M255669</link>
      <description>&lt;P&gt;I'm still grumpy. : )&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If PROC COMPARE was ODS compliant, it should be as easy as:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;ods trace on ;
ods output comparesummary=want ;
proc compare
  data=cl1
  compare=cl2
;
run;
ods trace off ;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;This little bit of the output you want clearly could be an ODS object / table:&lt;/P&gt;
&lt;PRE&gt;Variable  Type  Len  Ndif   MaxDif

Sex       CHAR    1     1
Age       NUM     8     1    1.000
&lt;/PRE&gt;
&lt;P&gt;But instead, currently PROC COMPARE provides ODS objects that are basically just fixed-length text output you would have to parse yourself:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc print data=want ;
run ;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;PRE&gt;Obs    type                                 batch

  1     d
  2     d
  3     h                            Observation Summary
  4     h
  5     h                       Observation      Base  Compare
  6     d
  7     d                       First Obs           1        1
  8     d                       First Unequal       7        7
  9     d                       Last  Unequal      10       10
 10     d                       Last  Obs          19       19
 11     d
 12     d      Number of Observations in Common: 19.
 13     d      Total Number of Observations Read from WORK.CL1: 19.
 14     d      Total Number of Observations Read from WORK.CL2: 19.
 15     d
 16     d      Number of Observations with Some Compared Variables Unequal: 2.
 17     d      Number of Observations with All Compared Variables Equal: 17.
 18     d
 19     d
 20     h                         Values Comparison Summary
 21     h
 22     d      Number of Variables Compared with All Observations Equal: 3.
 23     d      Number of Variables Compared with Some Observations Unequal: 2.
 24     d      Total Number of Values which Compare Unequal: 2.
 25     d      Maximum Difference: 1.
 26     d
 27     d
 28     h                       Variables with Unequal Values
 29     h
 30     h                    Variable  Type  Len  Ndif   MaxDif
 31     d
 32     d                    Sex       CHAR    1     1
 33     d                    Age       NUM     8     1    1.000
 34     d
&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 16 Feb 2022 18:02:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-compare-write-only-the-variable-names-with-difference/m-p/796653#M255669</guid>
      <dc:creator>Quentin</dc:creator>
      <dc:date>2022-02-16T18:02:09Z</dc:date>
    </item>
  </channel>
</rss>

