<?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 ? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/proc-compare/m-p/372281#M275996</link>
    <description>&lt;P&gt;Hello:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would like to change some variable names in old dataset.&amp;nbsp; I would like to compare those two variable names in Old and New dataset.&amp;nbsp; I use proc compare.&amp;nbsp;&amp;nbsp; However, i didn't see it list the details for the variable names.&amp;nbsp; How to get the complete list variables of both dataset?&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;STRONG&gt;Proc&lt;/STRONG&gt;&lt;/FONT&gt; &lt;STRONG&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;Compare&lt;/FONT&gt;&lt;/STRONG&gt; &lt;FONT color="#0000ff" face="Courier New" size="2"&gt;BASE&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;=&amp;amp;State &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;COMPARE&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;=&amp;amp;State.update &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;outnoequal&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="2"&gt;out&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;=toprint;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;TITLE1&lt;/FONT&gt; &lt;FONT color="#800080" face="Courier New" size="2"&gt;"&amp;amp;State original names vs Changed Names"&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;STRONG&gt;Run&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;</description>
    <pubDate>Fri, 30 Jun 2017 19:08:19 GMT</pubDate>
    <dc:creator>ybz12003</dc:creator>
    <dc:date>2017-06-30T19:08:19Z</dc:date>
    <item>
      <title>proc compare ?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-compare/m-p/372281#M275996</link>
      <description>&lt;P&gt;Hello:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would like to change some variable names in old dataset.&amp;nbsp; I would like to compare those two variable names in Old and New dataset.&amp;nbsp; I use proc compare.&amp;nbsp;&amp;nbsp; However, i didn't see it list the details for the variable names.&amp;nbsp; How to get the complete list variables of both dataset?&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;STRONG&gt;Proc&lt;/STRONG&gt;&lt;/FONT&gt; &lt;STRONG&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;Compare&lt;/FONT&gt;&lt;/STRONG&gt; &lt;FONT color="#0000ff" face="Courier New" size="2"&gt;BASE&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;=&amp;amp;State &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;COMPARE&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;=&amp;amp;State.update &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;outnoequal&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="2"&gt;out&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;=toprint;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;TITLE1&lt;/FONT&gt; &lt;FONT color="#800080" face="Courier New" size="2"&gt;"&amp;amp;State original names vs Changed Names"&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;STRONG&gt;Run&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 30 Jun 2017 19:08:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-compare/m-p/372281#M275996</guid>
      <dc:creator>ybz12003</dc:creator>
      <dc:date>2017-06-30T19:08:19Z</dc:date>
    </item>
    <item>
      <title>Re: proc compare ?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-compare/m-p/372287#M275997</link>
      <description>&lt;P&gt;Do you mean you renamed variables, and then want to compare the variables from the old dataset with the old names to the variables in the new dataset with the new names?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can use VAR statement and WITH statement to list the variables you want to compare, e.g.:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data myclass;
  set sashelp.class(rename=(height=MyHeight));
run;

proc compare base=sashelp.class compare=myclass;
  var height;
  with MyHeight;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 30 Jun 2017 19:35:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-compare/m-p/372287#M275997</guid>
      <dc:creator>Quentin</dc:creator>
      <dc:date>2017-06-30T19:35:23Z</dc:date>
    </item>
    <item>
      <title>Re: proc compare ?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-compare/m-p/372289#M275998</link>
      <description>&lt;P&gt;Is there a way to list the full variable names?&amp;nbsp; Not just the correct ones?&amp;nbsp; Thanks.&lt;/P&gt;</description>
      <pubDate>Fri, 30 Jun 2017 19:43:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-compare/m-p/372289#M275998</guid>
      <dc:creator>ybz12003</dc:creator>
      <dc:date>2017-06-30T19:43:15Z</dc:date>
    </item>
    <item>
      <title>Re: proc compare ?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-compare/m-p/372291#M275999</link>
      <description>I don't understand, maybe you could post an example?  You can list as many variables as you want on the VAR statement and the WITH statement.  You should have the same number of variables on both statements.  It will compare the first variable from each list, the second variable from each list, etc, regardless of the names.</description>
      <pubDate>Fri, 30 Jun 2017 19:47:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-compare/m-p/372291#M275999</guid>
      <dc:creator>Quentin</dc:creator>
      <dc:date>2017-06-30T19:47:21Z</dc:date>
    </item>
    <item>
      <title>Re: proc compare ?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-compare/m-p/372305#M276000</link>
      <description>&lt;P&gt;Maybe not exactly what you want but here is one way to only look at variable names:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;proc tabulate data=sashelp.vcolumn;
   where libname='WORK' and memname in ("SET1" "SET2");
   class memname name;
   table name,
         memname;
run;&lt;/PRE&gt;
&lt;P&gt;You will get a count of 1 under the Mename (data set name) when present.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Note that the value of Memname in sashelp.vcolumn is uppercase. So you would need to ensure that macro variables are in upper case.&lt;/P&gt;
&lt;P&gt;This approach&amp;nbsp;does have the nice feature that Proc Compare will never have: you could compare many sets at one time, just have each one in the where clause. If you wanted to look at all sets in a library then the "and memname in ..." part isn't needed.&lt;/P&gt;
&lt;P&gt;You could ask for other things such as type to know if the variable is numeric or character, or labels to see if they have the same label.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;SASHELP.Vcolum contains lots of information about all variables in all datasets in all libraries. So if you have many library/dataset combinations this may take a little while to run.&lt;/P&gt;</description>
      <pubDate>Fri, 30 Jun 2017 21:14:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-compare/m-p/372305#M276000</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2017-06-30T21:14:32Z</dc:date>
    </item>
    <item>
      <title>Re: proc compare ?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-compare/m-p/372307#M276001</link>
      <description>&lt;P&gt;I think you want the LISTALL option on the PROC COMPARE statement.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;Control the listing of variables and observations
LISTALL
lists all variables and observations that are found in only one data set.&lt;/PRE&gt;
&lt;P&gt;This is show in the output the variables that do not appear in both datasets.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Or perhaps instead of comparing the original datasets you want to compare the output from proc contents?&lt;/P&gt;</description>
      <pubDate>Fri, 30 Jun 2017 21:40:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-compare/m-p/372307#M276001</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2017-06-30T21:40:39Z</dc:date>
    </item>
    <item>
      <title>Re: proc compare ?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-compare/m-p/372313#M276002</link>
      <description>&lt;P&gt;Thanks for&amp;nbsp; all your promt reply.&amp;nbsp; I have 1000 variables, and 300 got rename.&amp;nbsp; I did use proc content then merge to compare the name.&amp;nbsp; It just I am curious if I could do this in one step by using proc compare.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 30 Jun 2017 22:06:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-compare/m-p/372313#M276002</guid>
      <dc:creator>ybz12003</dc:creator>
      <dc:date>2017-06-30T22:06:17Z</dc:date>
    </item>
    <item>
      <title>Re: proc compare ?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-compare/m-p/372355#M276003</link>
      <description>&lt;P&gt;Oh, so the goal is to get a list of variables that are in only one of the datasets, rather than comparing values of the data?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I like &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt;'s idea of PROC COMPARE LISTALL.&amp;nbsp; But I couldn't see an easy way to get an output dataset with the variables:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data myclass;
  set sashelp.class(rename=(height=MyHeight));
run;
          
proc compare base=sashelp.class compare=myclass listall;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Similar to &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13884"&gt;@ballardw&lt;/a&gt;'s approach, you use PROC SQL to read dictionary.columns and find the variables that are only in one dataset (but as noted before dictionary.columns gets BIG if you have a lot of libraries defined, so PROC CONTENTS out= followed by merge or SQL is certainly reasonable as well):&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
  select libname, memname, name
  from dictionary.columns
  where  (libname="SASHELP" and memname="CLASS")
      or (libname="WORK" and memname="MYCLASS")
  group by name
  having count(*)=1
  ;
quit; &lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 01 Jul 2017 02:42:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-compare/m-p/372355#M276003</guid>
      <dc:creator>Quentin</dc:creator>
      <dc:date>2017-07-01T02:42:33Z</dc:date>
    </item>
    <item>
      <title>Re: proc compare ?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-compare/m-p/372357#M276004</link>
      <description>&lt;P&gt;Even easier and very fast:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
proc compare base  =sashelp.class(obs=0) 
            compare=sashelp.class(drop=age obs=0) listall ;
run; &lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;SAS Output&lt;/P&gt;
&lt;DIV class="branch"&gt;
&lt;DIV&gt;
&lt;DIV align="center"&gt;
&lt;TABLE summary="Page Layout" cellpadding="0" cellspacing="0"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD&gt;
&lt;PRE class="batch"&gt; Listing of Variables in SASHELP.CLASS but not in SASHELP.CLASS                 
                                                                                               
                                    Variable  Type  Length                                     
                                                                                               
                                    Age       Num        8       &lt;/PRE&gt;
&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;</description>
      <pubDate>Sat, 01 Jul 2017 02:57:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-compare/m-p/372357#M276004</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2017-07-01T02:57:33Z</dc:date>
    </item>
  </channel>
</rss>

