<?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: Compare every variable between two datasets in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Compare-every-variable-between-two-datasets/m-p/174124#M33452</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Glad to help, going to take quite a while longer to run with 28,000 variables...&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 08 Jan 2015 19:04:02 GMT</pubDate>
    <dc:creator>FriedEgg</dc:creator>
    <dc:date>2015-01-08T19:04:02Z</dc:date>
    <item>
      <title>Compare every variable between two datasets</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Compare-every-variable-between-two-datasets/m-p/174117#M33445</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;With PROC COMPARE, I noticed that there is the ability to compare variables across datasets with different names using the VAR and WITH statements.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I need to compare a table with about 1,400 variables.&amp;nbsp; My base table has just 20 variables.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I want to see if any of the 20 variables in my base table have the same observations as one of the 1400 variables in the comparison table.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I do not know which names I should place in the WITH statement in advance.&amp;nbsp; I was wondering if there were options for PROC COMPARE that enabled you to compare the observations of the 20 variables with all 1400 variables?&amp;nbsp; And if there are, is there a better approach to finding variables from your base dataset that correspond to another variable (with a different name) in another dataset?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 08 Jan 2015 00:07:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Compare-every-variable-between-two-datasets/m-p/174117#M33445</guid>
      <dc:creator>rcclark2</dc:creator>
      <dc:date>2015-01-08T00:07:56Z</dc:date>
    </item>
    <item>
      <title>Re: Compare every variable between two datasets</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Compare-every-variable-between-two-datasets/m-p/174118#M33446</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The most simple answer to your question is no...&amp;nbsp; It can be done, but not with PROC COMPARE, and with such a comparison you should expect it to take a substantial amount of time to compute.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 08 Jan 2015 00:34:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Compare-every-variable-between-two-datasets/m-p/174118#M33446</guid>
      <dc:creator>FriedEgg</dc:creator>
      <dc:date>2015-01-08T00:34:37Z</dc:date>
    </item>
    <item>
      <title>Re: Compare every variable between two datasets</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Compare-every-variable-between-two-datasets/m-p/174119#M33447</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;How do you define "&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt; the same observations " ?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;Make an example to explain your question better .&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 08 Jan 2015 03:04:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Compare-every-variable-between-two-datasets/m-p/174119#M33447</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2015-01-08T03:04:35Z</dc:date>
    </item>
    <item>
      <title>Re: Compare every variable between two datasets</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Compare-every-variable-between-two-datasets/m-p/174120#M33448</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Should be a relatively simple two stage approach.&amp;nbsp; First identify matching variables, i.e. use sashelp.vcolumn merge where name in both datasets.&amp;nbsp; Then with that list build your proc compare.&amp;nbsp; Xia Keshan brings up a very good point however, if you are comparing just one variable against another you would need a set of common identifier variables.&amp;nbsp; (Note I haven't checked it, this is just to give idea):&lt;/P&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; create table LOOP as&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; select&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; distinct&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; COALESCE(A.NAME,B.NAME) as NAME&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; from&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; (select * from SASHELP.VCOLUMN where LIBNAME="libname" and MEMNAME="datasetname") A,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; (select * from SASHELP.VCOLUMN where LIBNAME="libname" and MEMNAME="comparedatasetname") B&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; where&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; A.NAME=B.NAME;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;P&gt;data _null_;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; set loop; /* For each name create a proc compare */&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; call execute('ods pdf file="compare_of_'||strip(name)||'.rtf";&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; proc compare data=....;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ods pdf close;');&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 08 Jan 2015 09:31:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Compare-every-variable-between-two-datasets/m-p/174120#M33448</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2015-01-08T09:31:23Z</dc:date>
    </item>
    <item>
      <title>Re: Compare every variable between two datasets</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Compare-every-variable-between-two-datasets/m-p/174121#M33449</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;FriedEgg:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I suspect you're right.&amp;nbsp; It very well may take a long time.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I could create a Macro loop and cycle through all of the 20 x 1400 variable combinations, testing each of the 20 variables against every one of the 1400 variables.&amp;nbsp; I could duplicate the entry of the variable I want to compare 1400 times in the VAR statement, and using PROC Contents, pass a macro variable containing the variable names from the 1400 variable dataset, to the WITH statement:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;From the SUGI paper:&lt;/P&gt;&lt;P&gt;&lt;A href="http://analytics.ncsu.edu/sesug/2003/TU01-Reiss.pdf" title="http://analytics.ncsu.edu/sesug/2003/TU01-Reiss.pdf"&gt;http://analytics.ncsu.edu/sesug/2003/TU01-Reiss.pdf&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The author suggests the following code for testing one variable against several:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc compare base = base-data-set&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; compare = compare-data-set&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; nosummary&lt;BR /&gt;;&lt;/P&gt;&lt;P&gt; var base-variable base-variable;&lt;/P&gt;&lt;P&gt; with compare-variable-#1 compare-variable-#2;&lt;/P&gt;&lt;P&gt;title1 'Compare One Variable (base-variable)’;&lt;BR /&gt;title2 ‘with Two Variables (compare-variable-#1 and compare-variable-#2)';&lt;BR /&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 08 Jan 2015 17:10:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Compare-every-variable-between-two-datasets/m-p/174121#M33449</guid>
      <dc:creator>rcclark2</dc:creator>
      <dc:date>2015-01-08T17:10:21Z</dc:date>
    </item>
    <item>
      <title>Re: Compare every variable between two datasets</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Compare-every-variable-between-two-datasets/m-p/174122#M33450</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Yes, you can compare a variable with more than one other variable.&amp;nbsp; I may have misread your question at first (still not 100% clear).&amp;nbsp; Assuming the following is a scaled down version of your problem:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;options mprint;&lt;/P&gt;&lt;P&gt;data a;&lt;/P&gt;&lt;P&gt;input id a b c;&lt;/P&gt;&lt;P&gt;cards;&lt;/P&gt;&lt;P&gt;1 1.1 1.2 1.3&lt;/P&gt;&lt;P&gt;2 2.1 2.2 2.3&lt;/P&gt;&lt;P&gt;3 3.1 3.2 3.3&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;data b;&lt;/P&gt;&lt;P&gt;input idx abc bcd cde def efg fgh;&lt;/P&gt;&lt;P&gt;cards;&lt;/P&gt;&lt;P&gt;1 1.1 1.2 1.3 1.4 1.5 1.6&lt;/P&gt;&lt;P&gt;2 2.1 2.2 2.3 2.4 2.5 2.6&lt;/P&gt;&lt;P&gt;3 3.1 3.2 3.3 2.4 2.5 2.6&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%macro crazy_compare();&lt;/P&gt;&lt;P&gt;%let a=%sysfunc(open(work.a));&lt;/P&gt;&lt;P&gt;%let b=%sysfunc(open(work.b));&lt;/P&gt;&lt;P&gt;proc compare base=a compare=b /*listequalvar novalues nodate*/ noprint outstat=foobar(where=(_type_='NDIF' and sum(_BASE_, _COMP_)=0));&lt;/P&gt;&lt;P&gt;var %do i=1 %to %sysfunc(attrn(&amp;amp;a., nvars));&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; %do j=1 %to %sysfunc(attrn(&amp;amp;b., nvars));&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; %sysfunc(varname(&amp;amp;a., &amp;amp;i.))&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; %end;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; %end;&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;with %do i=1 %to %sysfunc(attrn(&amp;amp;a., nvars));&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; %do j=1 %to %sysfunc(attrn(&amp;amp;b., nvars));&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; %sysfunc(varname(&amp;amp;b., &amp;amp;j.))&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; %end;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; %end;&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;%let rc=%sysfunc(close(&amp;amp;a.));&lt;/P&gt;&lt;P&gt;%let rc=%sysfunc(close(&amp;amp;b.));&lt;/P&gt;&lt;P&gt;%mend;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%crazy_compare&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data _null_;&lt;/P&gt;&lt;P&gt;set foobar;&lt;/P&gt;&lt;P&gt;put _var_ ' = ' _with_;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;id&amp;nbsp; = idx&lt;/P&gt;&lt;P&gt;a&amp;nbsp; = abc&lt;/P&gt;&lt;P&gt;b&amp;nbsp; = bcd&lt;/P&gt;&lt;P&gt;c&amp;nbsp; = cde&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 08 Jan 2015 18:12:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Compare-every-variable-between-two-datasets/m-p/174122#M33450</guid>
      <dc:creator>FriedEgg</dc:creator>
      <dc:date>2015-01-08T18:12:29Z</dc:date>
    </item>
    <item>
      <title>Re: Compare every variable between two datasets</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Compare-every-variable-between-two-datasets/m-p/174123#M33451</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;FriedEgg, this appears to be exactly what I was looking for.&amp;nbsp; Thank you very much.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 08 Jan 2015 18:42:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Compare-every-variable-between-two-datasets/m-p/174123#M33451</guid>
      <dc:creator>rcclark2</dc:creator>
      <dc:date>2015-01-08T18:42:14Z</dc:date>
    </item>
    <item>
      <title>Re: Compare every variable between two datasets</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Compare-every-variable-between-two-datasets/m-p/174124#M33452</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Glad to help, going to take quite a while longer to run with 28,000 variables...&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 08 Jan 2015 19:04:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Compare-every-variable-between-two-datasets/m-p/174124#M33452</guid>
      <dc:creator>FriedEgg</dc:creator>
      <dc:date>2015-01-08T19:04:02Z</dc:date>
    </item>
  </channel>
</rss>

