<?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: How to interpret  and simplify  proc compare results  in SAS 9.4 ? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-interpret-and-simplify-proc-compare-results-in-SAS-9-4/m-p/818907#M323262</link>
    <description>&lt;P&gt;Partial explanation:&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;The differences for character variables are noted with an X or a period (.). An X shows that the characters do not match. A period shows that the characters do match. For numeric variables, an E means that there is no difference.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;You can explore various Proc Compare options to customize&amp;nbsp;result, but for the details you require may need custom data step or proc sql code.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;For more Proc Compare details and examples see documentation:&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;A href="https://go.documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/proc/n1f136xdchlfrtn1663tmzklctb6.htm" target="_blank"&gt;https://go.documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/proc/n1f136xdchlfrtn1663tmzklctb6.htm&lt;/A&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 17 Jun 2022 18:28:36 GMT</pubDate>
    <dc:creator>JOL</dc:creator>
    <dc:date>2022-06-17T18:28:36Z</dc:date>
    <item>
      <title>How to interpret  and simplify  proc compare results  in SAS 9.4 ?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-interpret-and-simplify-proc-compare-results-in-SAS-9-4/m-p/818878#M323255</link>
      <description>&lt;P&gt;Hi experts,&lt;/P&gt;
&lt;P&gt;I have two datasets as follows:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data grad;
    input club $ win loss year champions $;
    datalines;
Grad_1 5 5 2019 none
Grad_2 4 6 2019 once
Grad_3 7 3 2019 twice
Grad_4 2 8 2019 none
;
run;

data postgrad;
    input club $ win loss champions $;
    datalines;
Pstgrd_1 6 4 once
Pstgrd_2 8 2 once
Pstgrd_3 2 8 none
Pstgrd_4 7 3 twice
;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I used proc compare:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc compare base= grad 
             compare= postgrad
			 out= comparison
             outnoequal outbase outcomp outdif;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;It gave me:&lt;/P&gt;
&lt;PRE&gt;                                        The COMPARE Procedure                                         
                              Comparison of WORK.GRAD with WORK.POSTGRAD                              
                                            (Method=EXACT)                                            
                                                                                                      
                                          Data Set Summary                                            
                                                                                                      
                   Dataset                 Created          Modified  NVar    NObs                    
                                                                                                      
                   WORK.GRAD      17JUN22:11:49:43  17JUN22:11:49:43     5       4                    
                   WORK.POSTGRAD  17JUN22:11:49:43  17JUN22:11:49:43     4       4                    
                                                                                                      
                                                                                                      
                                          Variables Summary                                           
                                                                                                      
                    Number of Variables in Common: 4.                                                 
                    Number of Variables in WORK.GRAD but not in WORK.POSTGRAD: 1.                     




                                                                                                      
                                                                                                      
                                         Observation Summary                                          
                                                                                                      
                                    Observation      Base  Compare                                    
                                                                                                      
                                    First Obs           1        1                                    
                                    First Unequal       1        1                                    
                                    Last  Unequal       4        4                                    
                                    Last  Obs           4        4                                    
                                                                                                      
                   Number of Observations in Common: 4.                                               
                   Total Number of Observations Read from WORK.GRAD: 4.                               
                   Total Number of Observations Read from WORK.POSTGRAD: 4.                           
                                                                                                      
                   Number of Observations with Some Compared Variables Unequal: 4.                    
                   Number of Observations with All Compared Variables Equal: 0.                       
                                                                                                      
                                                                                                      
                                      Values Comparison Summary                                       
                                                                                                      
                   Number of Variables Compared with All Observations Equal: 0.                       
                   Number of Variables Compared with Some Observations Unequal: 4.                    
                   Total Number of Values which Compare Unequal: 15.                                  
                   Maximum Difference: 5.                                                             
                                                                                                      






      The SAS System


                                        The COMPARE Procedure                                         
                              Comparison of WORK.GRAD with WORK.POSTGRAD                              
                                            (Method=EXACT)                                            
                                                                                                      
                              All Variables Compared have Unequal Values                              
                                                                                                      
                                Variable   Type  Len  Ndif   MaxDif                                   
                                                                                                      
                                club       CHAR    8     4                                            
                                win        NUM     8     4    5.000                                   
                                loss       NUM     8     4    5.000                                   
                                champions  CHAR    8     3                                            
                                                                                                      




                                                                                                      
                                                                                                      
                                Value Comparison Results for Variables                                
                                                                                                      
                      __________________________________________________________                      
                                 ||  Base Value           Compare Value                               
                             Obs ||  club                  club                                       
                       ________  ||  ________              ________                                   
                                 ||                                                                   
                              1  ||  Grad_1                Pstgrd_1                                   
                              2  ||  Grad_2                Pstgrd_2                                   
                              3  ||  Grad_3                Pstgrd_3                                   
                              4  ||  Grad_4                Pstgrd_4                                   
                      __________________________________________________________                      
                                                                                                      
                                                                                                      
                      __________________________________________________________                      
                                 ||       Base    Compare                                             
                             Obs ||        win        win      Diff.     % Diff                       
                       ________  ||  _________  _________  _________  _________                       
                                 ||                                                                   
                              1  ||     5.0000     6.0000     1.0000    20.0000                       
                              2  ||     4.0000     8.0000     4.0000   100.0000                       
                              3  ||     7.0000     2.0000    -5.0000   -71.4286                       
                              4  ||     2.0000     7.0000     5.0000   250.0000                       
                      __________________________________________________________                      
                                                                                                      
                                                                                                      
                      __________________________________________________________                      
                                 ||       Base    Compare                                             
                             Obs ||       loss       loss      Diff.     % Diff                       
                       ________  ||  _________  _________  _________  _________                       
                                 ||                                                                   
                              1  ||     5.0000     4.0000    -1.0000   -20.0000                       
                              2  ||     6.0000     2.0000    -4.0000   -66.6667                       
                              3  ||     3.0000     8.0000     5.0000   166.6667                       
                              4  ||     8.0000     3.0000    -5.0000   -62.5000                       
                      __________________________________________________________                      






      The SAS System


                                        The COMPARE Procedure                                         
                              Comparison of WORK.GRAD with WORK.POSTGRAD                              
                                            (Method=EXACT)                                            
                                                                                                      
                                Value Comparison Results for Variables                                
                                                                                                      
                      __________________________________________________________                      
                                 ||  Base Value           Compare Value                               
                             Obs ||  champions             champions                                  
                       ________  ||  ________              ________                                   
                                 ||                                                                   
                              1  ||  none                  once                                       
                              3  ||  twice                 none                                       
                              4  ||  none                  twice                                      
                      __________________________________________________________                      
&lt;/PRE&gt;
&lt;P&gt;Output dataset:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="inquistive_0-1655482225421.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/72390i91F3103961DDBF78/image-size/medium?v=v2&amp;amp;px=400" role="button" title="inquistive_0-1655482225421.png" alt="inquistive_0-1655482225421.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Now, I have some questions:&lt;/P&gt;
&lt;P&gt;1. Base&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Grad_1&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;Compare&amp;nbsp; Pstgrd_1&lt;/P&gt;
&lt;P&gt;&amp;nbsp; Diff:&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;XXXXXXXX&lt;/P&gt;
&lt;P&gt;&amp;nbsp; By&amp;nbsp;XXXXXXXX, what 8 difference is it showing? Is it showing Compare value's (under the variable 'club') length? X does not mean anything.&amp;nbsp; Why is it not&amp;nbsp; saying what exactly is different? For example: Grad_1 is 6 characters long and Pstgrd_1 is 8 characters long. Where is it showing what is different in the values?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;How can I change the code so that it tells me what and how are there any differences?&lt;/P&gt;
&lt;P&gt;I need it to say(Let's limit to character variable only here)-&lt;/P&gt;
&lt;P&gt;Grad_1 and Pstgrd_1 has a difference:&lt;/P&gt;
&lt;P&gt;Pstgrd...&lt;/P&gt;
&lt;P&gt;Grad...&lt;/P&gt;
&lt;P&gt;(still 'grd' are common letters.)&lt;/P&gt;
&lt;P&gt;It also has similarities:&lt;/P&gt;
&lt;P&gt;..._1&lt;/P&gt;
&lt;P&gt;..._1&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;2. How to interpret and output the differences(turning them something legible like&amp;nbsp; aA/bB/Cc or 1/2/3 ...etc. instead of a cryptic XXXX... ) through SAS code ?&lt;/P&gt;
&lt;P&gt;3. Suppose I capture the exact differences (through your expert tips and trick, of course&lt;span class="lia-unicode-emoji" title=":smiling_face_with_smiling_eyes:"&gt;😊&lt;/span&gt;), I now need to consolidate them into a single table. The problem is:&lt;/P&gt;
&lt;P&gt;&amp;nbsp; There are widespread differences between the compared values in almost all the cells/rows, I need to tell it to give me the value differences ( such as 'once' &amp;amp; 'none', 'twice' &amp;amp; 'none') whenever there is any difference. It needs&amp;nbsp; to tell me what the base(Grad_1) and compare values(Pstgrd_1) are and what differences exist between them .&lt;/P&gt;
&lt;P&gt;_obs_ and _type_ are&amp;nbsp; variables that are created by SAS, not my own program. Dif is attached to _Type_.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;How can I tell the program to:&lt;/P&gt;
&lt;P&gt;1.First see the base and compare variable values.&lt;/P&gt;
&lt;P&gt;2.Fnd the differences between them, if any&lt;/P&gt;
&lt;P&gt;3. Give me those differences.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
 create table comp as
   select CP.* 
    from comparison CP
    where CLUB like ('%X%') and and champions like ('X%')
 ;
 quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;It gave me:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="inquistive_1-1655486542604.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/72391i444866DC379AF892/image-size/medium?v=v2&amp;amp;px=400" role="button" title="inquistive_1-1655486542604.png" alt="inquistive_1-1655486542604.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;It did not tell me what the base and compare values were under the 'club' variable/column. I need to explain this table to&amp;nbsp; a layperson replacing the X and/or X... with letters /words/ numbers/signs etc., whatever applicable.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
    set comp(drop= _obs_ _type_);
 run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="inquistive_2-1655486916965.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/72392i3EE05E153D531B91/image-size/medium?v=v2&amp;amp;px=400" role="button" title="inquistive_2-1655486916965.png" alt="inquistive_2-1655486916965.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Could anyone tell me how to crack/solve this? I appreciate your help in advance.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Log-&lt;/P&gt;
&lt;P&gt;102 data grad;&lt;BR /&gt;103 input club $ win loss year champions $;&lt;BR /&gt;104 datalines;&lt;/P&gt;
&lt;P&gt;NOTE: The data set WORK.GRAD has 4 observations and 5 variables.&lt;BR /&gt;NOTE: DATA statement used (Total process time):&lt;BR /&gt;real time 0.01 seconds&lt;BR /&gt;cpu time 0.01 seconds&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;109 ;&lt;BR /&gt;110 run;&lt;BR /&gt;111&lt;BR /&gt;112 data postgrad;&lt;BR /&gt;113 input club $ win loss champions $;&lt;BR /&gt;114 datalines;&lt;/P&gt;
&lt;P&gt;NOTE: The data set WORK.POSTGRAD has 4 observations and 4 variables.&lt;BR /&gt;NOTE: DATA statement used (Total process time):&lt;BR /&gt;real time 0.01 seconds&lt;BR /&gt;cpu time 0.00 seconds&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;119 ;&lt;BR /&gt;120 run;&lt;BR /&gt;121&lt;BR /&gt;122 proc compare base= grad&lt;BR /&gt;123 compare= postgrad&lt;BR /&gt;124 out= comparison&lt;BR /&gt;125 outnoequal outbase outcomp outdif;&lt;BR /&gt;126 run;&lt;/P&gt;
&lt;P&gt;NOTE: There were 4 observations read from the data set WORK.GRAD.&lt;BR /&gt;NOTE: There were 4 observations read from the data set WORK.POSTGRAD.&lt;BR /&gt;NOTE: The data set WORK.COMPARISON has 12 observations and 6 variables.&lt;BR /&gt;NOTE: PROCEDURE COMPARE used (Total process time):&lt;BR /&gt;real time 0.03 seconds&lt;BR /&gt;cpu time 0.04 seconds&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;127&lt;BR /&gt;128 proc sql;&lt;BR /&gt;129 create table comp as&lt;BR /&gt;130 select CP.*&lt;BR /&gt;131 from comparison CP&lt;BR /&gt;132 where CLUB like ('%X%')and champions like ('X%')&lt;BR /&gt;133 ;&lt;BR /&gt;NOTE: Table WORK.COMP created, with 3 rows and 6 columns.&lt;/P&gt;
&lt;P&gt;134 quit;&lt;BR /&gt;NOTE: PROCEDURE SQL used (Total process time):&lt;BR /&gt;real time 0.01 seconds&lt;BR /&gt;cpu time 0.01 seconds&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;135&lt;BR /&gt;136 data test;&lt;BR /&gt;137 set comp(drop= _obs_ _type_);&lt;BR /&gt;138 run;&lt;/P&gt;
&lt;P&gt;NOTE: There were 3 observations read from the data set WORK.COMP.&lt;BR /&gt;NOTE: The data set WORK.TEST has 3 observations and 4 variables.&lt;BR /&gt;NOTE: DATA statement used (Total process time):&lt;BR /&gt;real time 0.01 seconds&lt;BR /&gt;cpu time 0.01 seconds&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 17 Jun 2022 18:21:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-interpret-and-simplify-proc-compare-results-in-SAS-9-4/m-p/818878#M323255</guid>
      <dc:creator>inquistive</dc:creator>
      <dc:date>2022-06-17T18:21:43Z</dc:date>
    </item>
    <item>
      <title>Re: How to interpret  and simplify  proc compare results  in SAS 9.4 ?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-interpret-and-simplify-proc-compare-results-in-SAS-9-4/m-p/818903#M323261</link>
      <description>&lt;P&gt;The X mark the locations where there are differences.&amp;nbsp; The periods mark locations where they are the same.&lt;/P&gt;
&lt;P&gt;Look at the output with FIXED width font, otherwise it is hard for humans to align the three strings and tell what they mean.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The one thing I would do is truncate DIF value to eliminate the extra dots. So truncate to the length of the longer of the two values being compared.&amp;nbsp; Your example variables are short ($8) so you don't see it. But if they were length $15 instead you would see something like:&lt;/P&gt;
&lt;PRE&gt;BASE    Grad_1                
COMPARE Pstgrd_1
DIF     XXXXXXXX.......          &lt;/PRE&gt;
&lt;P&gt;If you have some values where some of the character match it is also more obvious what the meaning of the X and . characters are in the DIF string.&lt;/P&gt;
&lt;PRE&gt;BASE    Grad_1                
COMPARE Pragrd_1
DIF     X..XXXXX.......   &amp;nbsp;&amp;nbsp;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 17 Jun 2022 18:22:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-interpret-and-simplify-proc-compare-results-in-SAS-9-4/m-p/818903#M323261</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-06-17T18:22:57Z</dc:date>
    </item>
    <item>
      <title>Re: How to interpret  and simplify  proc compare results  in SAS 9.4 ?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-interpret-and-simplify-proc-compare-results-in-SAS-9-4/m-p/818907#M323262</link>
      <description>&lt;P&gt;Partial explanation:&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;The differences for character variables are noted with an X or a period (.). An X shows that the characters do not match. A period shows that the characters do match. For numeric variables, an E means that there is no difference.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;You can explore various Proc Compare options to customize&amp;nbsp;result, but for the details you require may need custom data step or proc sql code.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;For more Proc Compare details and examples see documentation:&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;A href="https://go.documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/proc/n1f136xdchlfrtn1663tmzklctb6.htm" target="_blank"&gt;https://go.documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/proc/n1f136xdchlfrtn1663tmzklctb6.htm&lt;/A&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 17 Jun 2022 18:28:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-interpret-and-simplify-proc-compare-results-in-SAS-9-4/m-p/818907#M323262</guid>
      <dc:creator>JOL</dc:creator>
      <dc:date>2022-06-17T18:28:36Z</dc:date>
    </item>
    <item>
      <title>Re: How to interpret  and simplify  proc compare results  in SAS 9.4 ?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-interpret-and-simplify-proc-compare-results-in-SAS-9-4/m-p/818966#M323288</link>
      <description>Try option BRIEF TRANSPOSE.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;proc compare base= grad          brief transpose&lt;BR /&gt;             compare= postgrad&lt;BR /&gt;			 out= comparison&lt;BR /&gt;             outnoequal outbase outcomp outdif;&lt;BR /&gt;run;</description>
      <pubDate>Sat, 18 Jun 2022 10:03:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-interpret-and-simplify-proc-compare-results-in-SAS-9-4/m-p/818966#M323288</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2022-06-18T10:03:51Z</dc:date>
    </item>
  </channel>
</rss>

