<?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: simple summary of differences of wide datasets -- having trouble wrangling proc compare output in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/simple-summary-of-differences-of-wide-datasets-having-trouble/m-p/549342#M152415</link>
    <description>&lt;P&gt;Hi Chris. Sorry for the late reply, but THANK YOU very much! That works perfectly! Much appreciated.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Dave&lt;/P&gt;</description>
    <pubDate>Mon, 08 Apr 2019 17:23:21 GMT</pubDate>
    <dc:creator>ucdcrush</dc:creator>
    <dc:date>2019-04-08T17:23:21Z</dc:date>
    <item>
      <title>simple summary of differences of wide datasets -- having trouble wrangling proc compare output</title>
      <link>https://communities.sas.com/t5/SAS-Programming/simple-summary-of-differences-of-wide-datasets-having-trouble/m-p/547348#M151668</link>
      <description>&lt;P&gt;Hi all - here is the scenario.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have two datasets of identical structure, about 300 fields long, and that can share a common "id" variable.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'm trying to find out, in a concise way, which values (for the same variables) are different between these datasets, and what the differences are.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have tried proc compare.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc compare data=md5_imported
compare=md5_latest
outnoequal
out=md5_changes;
id acrfid;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The output displayed on the screen is great, as it shows the ID variable, the name of the variable that was different, and the values in the two datasets of those variables. That's everything I need, except I need to use that in data somewhere, so having it on the screen in the text output table isn't going to work.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;When I use the out= option, I get the table, but it's of course 300+ variables long, and I have to scroll over to find the column with an 'X' somewhere in the value to show me which field was different. Alas, it also does not tell me the value of that variable in either dataset &lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What I'm ideally looking for is to obtain something like this, in a dataset:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;ID&amp;nbsp; &amp;nbsp; &amp;nbsp;TableA&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; TableB&lt;/P&gt;
&lt;P&gt;1&amp;nbsp; &amp;nbsp; &amp;nbsp; Name-Daniel&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Name-Daniele&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;where "name" would be the name of the variable where there was a difference, "-" would be hardcoded as a separator, and "Daniel" or "Daniele" would be the value of that variable in each of those tables.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I think I might be able to get there -- somehow -- transposing the output from the proc compare table, then joining back to the original tables, but I have no idea how, and I have to imagine someone has already figured out a (better) way..&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;Any advice is appreciated, thank you.&lt;/P&gt;</description>
      <pubDate>Fri, 29 Mar 2019 21:54:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/simple-summary-of-differences-of-wide-datasets-having-trouble/m-p/547348#M151668</guid>
      <dc:creator>ucdcrush</dc:creator>
      <dc:date>2019-03-29T21:54:41Z</dc:date>
    </item>
    <item>
      <title>Re: simple summary of differences of wide datasets -- having trouble wrangling proc compare output</title>
      <link>https://communities.sas.com/t5/SAS-Programming/simple-summary-of-differences-of-wide-datasets-having-trouble/m-p/547527#M151738</link>
      <description>&lt;P&gt;Like this (assumes observation order and number match)?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro compare(ds1=,ds2=);
  %local i varnames nbvars;
  proc contents data=&amp;amp;ds1 out=CONT1 noprint; run;
  proc contents data=&amp;amp;ds2 out=CONT2 noprint; run;
  proc sql noprint;
    create table VARIABLES_IN_ONLY_ONE_TABLE as 
    (select NAME,'A' as TABLE from CONT1 except select NAME,'A' from CONT2)
     union
    (select NAME,'B' from CONT2 except select NAME,'B' from CONT1) ;
    select CONT1.NAME into :varnames separated by ' ' from CONT1, CONT2 where CONT1.NAME=CONT2.NAME;
  quit;
  %let nbvars=%sysfunc(countw(&amp;amp;varnames)); 
  data COMPARE;
    merge &amp;amp;ds1 (rename=(%do i=1%to&amp;amp;nbvars;%scan(&amp;amp;varnames,&amp;amp;i)=_%scan(&amp;amp;varnames,&amp;amp;i)%end;))
          &amp;amp;ds2;
   %do i=1%to&amp;amp;nbvars;
     if %scan(&amp;amp;varnames,&amp;amp;i) ne _%scan(&amp;amp;varnames,&amp;amp;i) then do;
       TABLEA=cats("%scan(&amp;amp;varnames,&amp;amp;i)-", %scan(&amp;amp;varnames,&amp;amp;i)); 
       TABLEB=cats("%scan(&amp;amp;varnames,&amp;amp;i)-",_%scan(&amp;amp;varnames,&amp;amp;i));
       output; 
     end;
   %end;
   keep TABLE:;
  run;
%mend;

data CLASS; 
  set SASHELP.CLASS; 
  drop SEX; 
  if _N_&amp;lt;3 then AGE =10  ;
  if _N_=1 then NAME='Jo';
run;

%compare(ds1=CLASS, ds2=SASHELP.CLASS);
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;DIV class="branch"&gt;
&lt;DIV&gt;
&lt;DIV align="center"&gt;
&lt;TABLE class="table" summary="Procedure Print: Data Set WORK.COMPARE" frame="box" rules="all" cellspacing="0" cellpadding="5"&gt;&lt;COLGROUP&gt; &lt;COL /&gt;&lt;/COLGROUP&gt; &lt;COLGROUP&gt; &lt;COL /&gt; &lt;COL /&gt;&lt;/COLGROUP&gt;
&lt;THEAD&gt;
&lt;TR&gt;
&lt;TH class="r header" scope="col"&gt;Obs&lt;/TH&gt;
&lt;TH class="l header" scope="col"&gt;TABLEA&lt;/TH&gt;
&lt;TH class="l header" scope="col"&gt;TABLEB&lt;/TH&gt;
&lt;/TR&gt;
&lt;/THEAD&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TH class="r rowheader" scope="row"&gt;1&lt;/TH&gt;
&lt;TD class="l data"&gt;Age-14&lt;/TD&gt;
&lt;TD class="l data"&gt;Age-10&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TH class="r rowheader" scope="row"&gt;2&lt;/TH&gt;
&lt;TD class="l data"&gt;Name-Alfred&lt;/TD&gt;
&lt;TD class="l data"&gt;Name-Jo&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TH class="r rowheader" scope="row"&gt;3&lt;/TH&gt;
&lt;TD class="l data"&gt;Age-13&lt;/TD&gt;
&lt;TD class="l data"&gt;Age-10&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&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;</description>
      <pubDate>Sun, 31 Mar 2019 22:47:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/simple-summary-of-differences-of-wide-datasets-having-trouble/m-p/547527#M151738</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2019-03-31T22:47:36Z</dc:date>
    </item>
    <item>
      <title>Re: simple summary of differences of wide datasets -- having trouble wrangling proc compare output</title>
      <link>https://communities.sas.com/t5/SAS-Programming/simple-summary-of-differences-of-wide-datasets-having-trouble/m-p/549342#M152415</link>
      <description>&lt;P&gt;Hi Chris. Sorry for the late reply, but THANK YOU very much! That works perfectly! Much appreciated.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Dave&lt;/P&gt;</description>
      <pubDate>Mon, 08 Apr 2019 17:23:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/simple-summary-of-differences-of-wide-datasets-having-trouble/m-p/549342#M152415</guid>
      <dc:creator>ucdcrush</dc:creator>
      <dc:date>2019-04-08T17:23:21Z</dc:date>
    </item>
  </channel>
</rss>

