<?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: Create data set &amp;quot;CompareDifferences&amp;quot; from proc compare. in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Create-data-set-quot-CompareDifferences-quot-from-proc-compare/m-p/17522#M3329</link>
    <description>ODS Tables and ODS TRACE...&lt;BR /&gt;
&lt;BR /&gt;
data one;&lt;BR /&gt;
   input student year $ state $ gr1 gr2;&lt;BR /&gt;
   label year='Year of Birth';&lt;BR /&gt;
   format gr1 4.1;&lt;BR /&gt;
   datalines;&lt;BR /&gt;
1000 1970 NC 85 87&lt;BR /&gt;
1042 1971 MD 92 92&lt;BR /&gt;
1095 1969 PA 78 72&lt;BR /&gt;
1187 1970 MA 87 94&lt;BR /&gt;
;&lt;BR /&gt;
&lt;BR /&gt;
data two;&lt;BR /&gt;
   input student $ year $ state $ gr1&lt;BR /&gt;
         gr2 major $;&lt;BR /&gt;
   label state='Home State';&lt;BR /&gt;
   format gr1 5.2;&lt;BR /&gt;
   datalines;&lt;BR /&gt;
1000 1970 NC 84 87 Math&lt;BR /&gt;
1042 1971 MA 92 92 History&lt;BR /&gt;
1095 1969 PA 79 73 Physics&lt;BR /&gt;
1187 1970 MD 87 74 Dance&lt;BR /&gt;
1204 1971 NC 82 96 French&lt;BR /&gt;
;&lt;BR /&gt;
&lt;BR /&gt;
ods trace on;&lt;BR /&gt;
proc compare base=one&lt;BR /&gt;
             compare=two novalues;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
ods table CompareVariables=Check1;&lt;BR /&gt;
proc compare base=one&lt;BR /&gt;
             compare=two novalues;&lt;BR /&gt;
run;</description>
    <pubDate>Fri, 15 Oct 2010 23:56:33 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2010-10-15T23:56:33Z</dc:date>
    <item>
      <title>Create data set "CompareDifferences" from proc compare.</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Create-data-set-quot-CompareDifferences-quot-from-proc-compare/m-p/17521#M3328</link>
      <description>Hello,&lt;BR /&gt;
So some SAS procedures assign names to the tables that they create.&lt;BR /&gt;
Proc compare also assign such names, few of them:"CompareDifferences","CompareVariables" etc.&lt;BR /&gt;
&lt;BR /&gt;
I want to make data set which consists of data from "CompareDifferences".&lt;BR /&gt;
&lt;BR /&gt;
I know that when using ODS, exists possibility to create output data sets by referencing these names, but I can't find any code which show's how to do it...&lt;BR /&gt;
&lt;BR /&gt;
Suppose it must be simple using of some ODS and proc compare options...&lt;BR /&gt;
&lt;BR /&gt;
Thanks!</description>
      <pubDate>Fri, 15 Oct 2010 10:33:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Create-data-set-quot-CompareDifferences-quot-from-proc-compare/m-p/17521#M3328</guid>
      <dc:creator>Yuriy2301</dc:creator>
      <dc:date>2010-10-15T10:33:16Z</dc:date>
    </item>
    <item>
      <title>Re: Create data set "CompareDifferences" from proc compare.</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Create-data-set-quot-CompareDifferences-quot-from-proc-compare/m-p/17522#M3329</link>
      <description>ODS Tables and ODS TRACE...&lt;BR /&gt;
&lt;BR /&gt;
data one;&lt;BR /&gt;
   input student year $ state $ gr1 gr2;&lt;BR /&gt;
   label year='Year of Birth';&lt;BR /&gt;
   format gr1 4.1;&lt;BR /&gt;
   datalines;&lt;BR /&gt;
1000 1970 NC 85 87&lt;BR /&gt;
1042 1971 MD 92 92&lt;BR /&gt;
1095 1969 PA 78 72&lt;BR /&gt;
1187 1970 MA 87 94&lt;BR /&gt;
;&lt;BR /&gt;
&lt;BR /&gt;
data two;&lt;BR /&gt;
   input student $ year $ state $ gr1&lt;BR /&gt;
         gr2 major $;&lt;BR /&gt;
   label state='Home State';&lt;BR /&gt;
   format gr1 5.2;&lt;BR /&gt;
   datalines;&lt;BR /&gt;
1000 1970 NC 84 87 Math&lt;BR /&gt;
1042 1971 MA 92 92 History&lt;BR /&gt;
1095 1969 PA 79 73 Physics&lt;BR /&gt;
1187 1970 MD 87 74 Dance&lt;BR /&gt;
1204 1971 NC 82 96 French&lt;BR /&gt;
;&lt;BR /&gt;
&lt;BR /&gt;
ods trace on;&lt;BR /&gt;
proc compare base=one&lt;BR /&gt;
             compare=two novalues;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
ods table CompareVariables=Check1;&lt;BR /&gt;
proc compare base=one&lt;BR /&gt;
             compare=two novalues;&lt;BR /&gt;
run;</description>
      <pubDate>Fri, 15 Oct 2010 23:56:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Create-data-set-quot-CompareDifferences-quot-from-proc-compare/m-p/17522#M3329</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2010-10-15T23:56:33Z</dc:date>
    </item>
    <item>
      <title>Re: Create data set "CompareDifferences" from proc compare.</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Create-data-set-quot-CompareDifferences-quot-from-proc-compare/m-p/17523#M3330</link>
      <description>That never really gives me what I want though, so I use the following macro. &lt;BR /&gt;
&lt;BR /&gt;
*Macro to compare data sets and produce the different columns/types;&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
%macro compare_data(dtset1, dtset2);&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
*Import the variable names, type, length and format from the sas dictionary tables;&lt;BR /&gt;
data dataset1;&lt;BR /&gt;
	set sashelp.vcolumn;&lt;BR /&gt;
	where libname="WORK" and memname="%quote(%upcase(&amp;amp;dtset1))";&lt;BR /&gt;
&lt;BR /&gt;
	name=upcase(name);&lt;BR /&gt;
	keep name type length format;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
*Import the variable names, type, length and format from the sas dictionary tables;&lt;BR /&gt;
data dataset2;&lt;BR /&gt;
	set sashelp.vcolumn;&lt;BR /&gt;
	where libname="WORK" and memname="%quote(%upcase(&amp;amp;dtset2))";&lt;BR /&gt;
&lt;BR /&gt;
	name=upcase(Name);&lt;BR /&gt;
&lt;BR /&gt;
	keep name type length format;&lt;BR /&gt;
	rename type=type2 length=length2 format=format2;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
proc sort data=dataset1; by name;&lt;BR /&gt;
proc sort data=dataset2; by name;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
*Compare the variable types, format and names;&lt;BR /&gt;
data comparison;&lt;BR /&gt;
	&lt;BR /&gt;
&lt;BR /&gt;
	format check $50. data_source $50.;&lt;BR /&gt;
	merge dataset1 (in=a) dataset2 (in=b);&lt;BR /&gt;
	by name;&lt;BR /&gt;
&lt;BR /&gt;
	*Initially set all to verification status;&lt;BR /&gt;
	check="1-Check me"; *Should only show up when variables are in diff data sets;&lt;BR /&gt;
&lt;BR /&gt;
	if a and b then do;&lt;BR /&gt;
		if type=type2 and format=format2 then check="4 - Match"; *If matched of least interest;&lt;BR /&gt;
		if  format ne format2 then check="3 - DIFF FORMAT"; *If diff format, note the formats so that it can be compared;&lt;BR /&gt;
		if type ne type2 then check= "2- DIFF TYPE"; *if diff types, note so that it can be fixed;&lt;BR /&gt;
	end;&lt;BR /&gt;
&lt;BR /&gt;
	*If variable is in one data set and not another set the dataset name;&lt;BR /&gt;
	if a and not b then data_source="&amp;amp;dtset1.";&lt;BR /&gt;
	else if b and not a then data_source="&amp;amp;dtset2.";&lt;BR /&gt;
	else if a and b then data_source="Both";&lt;BR /&gt;
&lt;BR /&gt;
	*Get rid of all labels;&lt;BR /&gt;
	attrib _all_ label="";&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
*Sort by preference of order type;&lt;BR /&gt;
proc sort data=comparison;&lt;BR /&gt;
	by check name;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
%mend;</description>
      <pubDate>Fri, 15 Oct 2010 23:59:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Create-data-set-quot-CompareDifferences-quot-from-proc-compare/m-p/17523#M3330</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2010-10-15T23:59:16Z</dc:date>
    </item>
    <item>
      <title>Re: Create data set "CompareDifferences" from proc compare.</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Create-data-set-quot-CompareDifferences-quot-from-proc-compare/m-p/17524#M3331</link>
      <description>Hi,&lt;BR /&gt;
Thanks for your answer!&lt;BR /&gt;
Now I understand why I couldn't find how to create this table - it's really show info in uncomfortable way... &lt;BR /&gt;
I also used some self-made macro to compare tables before, may be I'll merge this my macro with your and I'll have smth. better then proc compare:).&lt;BR /&gt;
&lt;BR /&gt;
Thanks!</description>
      <pubDate>Mon, 18 Oct 2010 07:52:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Create-data-set-quot-CompareDifferences-quot-from-proc-compare/m-p/17524#M3331</guid>
      <dc:creator>Yuriy2301</dc:creator>
      <dc:date>2010-10-18T07:52:59Z</dc:date>
    </item>
  </channel>
</rss>

