<?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 Comparing variable order between 2 datasets in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Comparing-variable-order-between-2-datasets/m-p/197876#M49448</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;We use proc compare to validate dataset output--that both datasets have the same records, same number of variables, and all values match.&amp;nbsp; But is there a fast-n-easy way to compare the *order* of the variables?&amp;nbsp; If I have one dataset with columns left to right VAR1 VAR2 VAR3, and another dataset with columns left to right VAR2 VAR3 VAR1, proc compare only catches if there is a difference in the values or number of records.&amp;nbsp; I'm looking for a way to validate that the variables are in the order we expect, and just wondered if there was a SAS option or command or macro that will do this quickly?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Many thanks,&lt;/P&gt;&lt;P&gt;Suzy&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 13 Aug 2015 00:47:17 GMT</pubDate>
    <dc:creator>SuzyG_</dc:creator>
    <dc:date>2015-08-13T00:47:17Z</dc:date>
    <item>
      <title>Comparing variable order between 2 datasets</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Comparing-variable-order-between-2-datasets/m-p/197876#M49448</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;We use proc compare to validate dataset output--that both datasets have the same records, same number of variables, and all values match.&amp;nbsp; But is there a fast-n-easy way to compare the *order* of the variables?&amp;nbsp; If I have one dataset with columns left to right VAR1 VAR2 VAR3, and another dataset with columns left to right VAR2 VAR3 VAR1, proc compare only catches if there is a difference in the values or number of records.&amp;nbsp; I'm looking for a way to validate that the variables are in the order we expect, and just wondered if there was a SAS option or command or macro that will do this quickly?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Many thanks,&lt;/P&gt;&lt;P&gt;Suzy&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 13 Aug 2015 00:47:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Comparing-variable-order-between-2-datasets/m-p/197876#M49448</guid>
      <dc:creator>SuzyG_</dc:creator>
      <dc:date>2015-08-13T00:47:17Z</dc:date>
    </item>
    <item>
      <title>Re: Comparing variable order between 2 datasets</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Comparing-variable-order-between-2-datasets/m-p/197877#M49449</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;you can do:&lt;/P&gt;&lt;P&gt;data new;&lt;/P&gt;&lt;P&gt;retain VAR1 VAR2 VAR3;&lt;/P&gt;&lt;P&gt;set existing_data;run;&lt;/P&gt;&lt;P&gt;hope it helps!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 13 Aug 2015 01:30:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Comparing-variable-order-between-2-datasets/m-p/197877#M49449</guid>
      <dc:creator>ursula</dc:creator>
      <dc:date>2015-08-13T01:30:19Z</dc:date>
    </item>
    <item>
      <title>Re: Comparing variable order between 2 datasets</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Comparing-variable-order-between-2-datasets/m-p/197878#M49450</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Suzy,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The way i know is the use of proc contents, output dataset with variable name and order. Then comparing the two datasets. Hope it helps &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data test;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; d=2;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; b001 =1;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; b002 =2;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; b003 =3;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; b001z=1;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; B001a=2;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; CaSeSeNsItIvE2=9;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; CASESENSITIVE3=9;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; D=2;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; casesensitive1=9;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; CaSeSeNsItIvE1a=9;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; d001z=1;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; CASESENSITIVE1C=9;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; D001a=2;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; casesensitive1b=9;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; A =1;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; a002 =2;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; a =3;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; a001z=1;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; A001a=2;&lt;/P&gt;&lt;P&gt; run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; data test2;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; casesensitive1=9;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; CaSeSeNsItIvE1a=9;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; d001z=1;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; CASESENSITIVE1C=9;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; D001a=2;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; casesensitive1b=9;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; A =1;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; a002 =2;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; a =3;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; a001z=1;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; A001a=2;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; d=2;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; b001 =1;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; b002 =2;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; b003 =3;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; b001z=1;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; B001a=2;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; CaSeSeNsItIvE2=9;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; CASESENSITIVE3=9;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; D=2;&lt;/P&gt;&lt;P&gt; run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; proc contents data=test out=ord(keep=name varnum) order=varnum;&lt;/P&gt;&lt;P&gt; run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; proc contents data=test2 out=ord2(keep=name varnum) order=varnum;&lt;/P&gt;&lt;P&gt; run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; proc compare base=ord compare=ord2 listall;&lt;/P&gt;&lt;P&gt; id name;&lt;/P&gt;&lt;P&gt; run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Jag&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 13 Aug 2015 01:43:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Comparing-variable-order-between-2-datasets/m-p/197878#M49450</guid>
      <dc:creator>Jagadishkatam</dc:creator>
      <dc:date>2015-08-13T01:43:49Z</dc:date>
    </item>
    <item>
      <title>Re: Comparing variable order between 2 datasets</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Comparing-variable-order-between-2-datasets/m-p/197879#M49451</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;One way to get a list of out of order variables:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;proc sql;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;create table expect (var1 real, var2 real, var3 real);&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;create table other&amp;nbsp; (var2 real, var3 real, var1 real);&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;quit;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;title "Variables out of order in dataset OTHER";&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;proc sql;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;select *&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;from&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;(&amp;nbsp;&amp;nbsp; select name, varnum "Wrong Order" from dictionary.columns&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; where libname = "WORK" and memname="OTHER" )&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;except&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;(&amp;nbsp;&amp;nbsp; select name, varnum from dictionary.columns&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; where libname = "WORK" and memname="EXPECT" );&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;quit;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PG&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 13 Aug 2015 01:47:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Comparing-variable-order-between-2-datasets/m-p/197879#M49451</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2015-08-13T01:47:56Z</dc:date>
    </item>
  </channel>
</rss>

