<?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: Merge of two dataset with keeping the orders in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Merge-of-two-dataset-with-keeping-the-orders/m-p/216409#M53266</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Dear all,&lt;/P&gt;&lt;P&gt;Thank you for reply and sorry to take you to ambiguous question.&lt;/P&gt;&lt;P&gt;Specifically speaking,I want to know the difference of valiables of two datasets,&lt;BR /&gt;these datasets have almost same valiables.Additionally, valiable's parts are grouping semantically,&lt;/P&gt;&lt;P&gt;so result dataset needs to keep orders.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;First I got these detasets included valiable name of each dataset by proc contents. And then,want to compare&lt;BR /&gt;these datasets...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ex)&lt;BR /&gt;dataset1:&lt;BR /&gt;[name]&lt;BR /&gt;id&lt;BR /&gt;fname&lt;BR /&gt;lname&lt;BR /&gt;maintest1&lt;BR /&gt;maintest2&lt;BR /&gt;subtest1&lt;BR /&gt;subtest2&lt;BR /&gt;date1&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;dataset2:&lt;BR /&gt;[name]&lt;BR /&gt;id&lt;BR /&gt;id_sub&lt;BR /&gt;fname&lt;BR /&gt;lname&lt;BR /&gt;maintest1&lt;BR /&gt;maintest2&lt;BR /&gt;maintest2_2&lt;BR /&gt;subtest1&lt;BR /&gt;date1&lt;BR /&gt;date1_sub&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;want dataset:&lt;BR /&gt;[inDS1 inDS2 valname]&lt;BR /&gt;1&amp;nbsp; 1&amp;nbsp; id&lt;BR /&gt;0&amp;nbsp; 1&amp;nbsp; id_sub&lt;BR /&gt;1&amp;nbsp; 1&amp;nbsp; fname&lt;BR /&gt;1&amp;nbsp; 1&amp;nbsp; lname&lt;BR /&gt;1&amp;nbsp; 1&amp;nbsp; maintest1&lt;BR /&gt;1&amp;nbsp; 1&amp;nbsp; maintest2&lt;BR /&gt;0&amp;nbsp; 1&amp;nbsp; maintest2_2&lt;BR /&gt;1&amp;nbsp; 1&amp;nbsp; subtest1&lt;BR /&gt;1&amp;nbsp; 0&amp;nbsp; subtest2&lt;BR /&gt;1&amp;nbsp; 1&amp;nbsp; date1&lt;BR /&gt;0&amp;nbsp; 1&amp;nbsp; date1_sub&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 05 Aug 2015 01:21:04 GMT</pubDate>
    <dc:creator>Hoz</dc:creator>
    <dc:date>2015-08-05T01:21:04Z</dc:date>
    <item>
      <title>Merge of two dataset with keeping the orders</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Merge-of-two-dataset-with-keeping-the-orders/m-p/216405#M53262</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have following two datasets.&lt;/P&gt;&lt;P&gt;dataset1:&lt;/P&gt;&lt;P&gt;[neme_value]&lt;/P&gt;&lt;P&gt;name1&lt;/P&gt;&lt;P&gt;name2&lt;/P&gt;&lt;P&gt;name3&lt;/P&gt;&lt;P&gt;...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;dataset2:&lt;/P&gt;&lt;P&gt;[name_value]&lt;/P&gt;&lt;P&gt;name1&lt;/P&gt;&lt;P&gt;namea&lt;/P&gt;&lt;P&gt;nameb&lt;/P&gt;&lt;P&gt;name3&lt;/P&gt;&lt;P&gt;namee&lt;/P&gt;&lt;P&gt;...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'd like to require following dataset.&lt;/P&gt;&lt;P&gt;resultdataset:&lt;/P&gt;&lt;P&gt;[name_value]&lt;/P&gt;&lt;P&gt;name1&lt;/P&gt;&lt;P&gt;name2&lt;/P&gt;&lt;P&gt;namea&lt;/P&gt;&lt;P&gt;nameb&lt;/P&gt;&lt;P&gt;name3&lt;/P&gt;&lt;P&gt;namee&lt;/P&gt;&lt;P&gt;...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I can't get it by this code.&lt;/P&gt;&lt;P&gt;data resultdataset;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; merge dataset1 dataset2;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; by notsorted name_value;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;Please tell me the way to get that result.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hide&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 04 Aug 2015 09:53:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Merge-of-two-dataset-with-keeping-the-orders/m-p/216405#M53262</guid>
      <dc:creator>Hoz</dc:creator>
      <dc:date>2015-08-04T09:53:48Z</dc:date>
    </item>
    <item>
      <title>Re: Merge of two dataset with keeping the orders</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Merge-of-two-dataset-with-keeping-the-orders/m-p/216406#M53263</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;My first question would be why?&amp;nbsp; Logically speaking there is no validity in a a random order like that.&amp;nbsp; You would be better off working out a good and reproducible output rather than something like this, if the first dataset is changed, then you may find the output dataset is no longer like a previous version.&amp;nbsp; If you still want to go ahead, then assign a variable to _n_ in both instances:&lt;/P&gt;&lt;P&gt;data inter1;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; set dataset1;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; nvar=_n_;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;data inter2;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; set dataset2;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; nvar=_n_;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;data want;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; merge inter1 inter2;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; by name_value;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;proc sort data=want;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; by nvar name_value;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;run;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;But then again, why.&amp;nbsp; To use the data in any meaningful way later on you will have to sort it anyways. &lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 04 Aug 2015 10:25:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Merge-of-two-dataset-with-keeping-the-orders/m-p/216406#M53263</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2015-08-04T10:25:41Z</dc:date>
    </item>
    <item>
      <title>Re: Merge of two dataset with keeping the orders</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Merge-of-two-dataset-with-keeping-the-orders/m-p/216407#M53264</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;What is the logic for where to place name2 in the output dataset?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 04 Aug 2015 11:10:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Merge-of-two-dataset-with-keeping-the-orders/m-p/216407#M53264</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2015-08-04T11:10:56Z</dc:date>
    </item>
    <item>
      <title>Re: Merge of two dataset with keeping the orders</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Merge-of-two-dataset-with-keeping-the-orders/m-p/216408#M53265</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data have1;&lt;BR /&gt;input name_value $5.;&lt;BR /&gt;datalines;&lt;BR /&gt;name1&lt;BR /&gt;name2&lt;BR /&gt;name3&lt;BR /&gt;;&lt;/P&gt;&lt;P&gt; &lt;BR /&gt;data have2;&lt;BR /&gt;input name_value $5.;&lt;BR /&gt;datalines;&lt;BR /&gt;name1&lt;BR /&gt;namea&lt;BR /&gt;nameb&lt;BR /&gt;name3&lt;BR /&gt;namee&lt;BR /&gt;;&lt;/P&gt;&lt;P&gt;proc sort data=have1 presorted;&lt;BR /&gt;by name_value;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;proc sort data=have2 presorted;&lt;BR /&gt;by name_value;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;data want;&lt;BR /&gt;update have2 have1;&lt;BR /&gt;by name_value;&lt;BR /&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 04 Aug 2015 12:29:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Merge-of-two-dataset-with-keeping-the-orders/m-p/216408#M53265</guid>
      <dc:creator>Loko</dc:creator>
      <dc:date>2015-08-04T12:29:29Z</dc:date>
    </item>
    <item>
      <title>Re: Merge of two dataset with keeping the orders</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Merge-of-two-dataset-with-keeping-the-orders/m-p/216409#M53266</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Dear all,&lt;/P&gt;&lt;P&gt;Thank you for reply and sorry to take you to ambiguous question.&lt;/P&gt;&lt;P&gt;Specifically speaking,I want to know the difference of valiables of two datasets,&lt;BR /&gt;these datasets have almost same valiables.Additionally, valiable's parts are grouping semantically,&lt;/P&gt;&lt;P&gt;so result dataset needs to keep orders.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;First I got these detasets included valiable name of each dataset by proc contents. And then,want to compare&lt;BR /&gt;these datasets...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ex)&lt;BR /&gt;dataset1:&lt;BR /&gt;[name]&lt;BR /&gt;id&lt;BR /&gt;fname&lt;BR /&gt;lname&lt;BR /&gt;maintest1&lt;BR /&gt;maintest2&lt;BR /&gt;subtest1&lt;BR /&gt;subtest2&lt;BR /&gt;date1&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;dataset2:&lt;BR /&gt;[name]&lt;BR /&gt;id&lt;BR /&gt;id_sub&lt;BR /&gt;fname&lt;BR /&gt;lname&lt;BR /&gt;maintest1&lt;BR /&gt;maintest2&lt;BR /&gt;maintest2_2&lt;BR /&gt;subtest1&lt;BR /&gt;date1&lt;BR /&gt;date1_sub&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;want dataset:&lt;BR /&gt;[inDS1 inDS2 valname]&lt;BR /&gt;1&amp;nbsp; 1&amp;nbsp; id&lt;BR /&gt;0&amp;nbsp; 1&amp;nbsp; id_sub&lt;BR /&gt;1&amp;nbsp; 1&amp;nbsp; fname&lt;BR /&gt;1&amp;nbsp; 1&amp;nbsp; lname&lt;BR /&gt;1&amp;nbsp; 1&amp;nbsp; maintest1&lt;BR /&gt;1&amp;nbsp; 1&amp;nbsp; maintest2&lt;BR /&gt;0&amp;nbsp; 1&amp;nbsp; maintest2_2&lt;BR /&gt;1&amp;nbsp; 1&amp;nbsp; subtest1&lt;BR /&gt;1&amp;nbsp; 0&amp;nbsp; subtest2&lt;BR /&gt;1&amp;nbsp; 1&amp;nbsp; date1&lt;BR /&gt;0&amp;nbsp; 1&amp;nbsp; date1_sub&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 05 Aug 2015 01:21:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Merge-of-two-dataset-with-keeping-the-orders/m-p/216409#M53266</guid>
      <dc:creator>Hoz</dc:creator>
      <dc:date>2015-08-05T01:21:04Z</dc:date>
    </item>
    <item>
      <title>Re: Merge of two dataset with keeping the orders</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Merge-of-two-dataset-with-keeping-the-orders/m-p/216410#M53267</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I don't see how order matters.&lt;/P&gt;&lt;P&gt;And you can use SASHELP.VCOLUMNS to simplify your query.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here's a macro I wrote to solve the problem a while back but&amp;nbsp; you can easily remove the macro portion if you don't need it:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="https://gist.github.com/statgeek/e0b98c4627aa31a567e5" title="https://gist.github.com/statgeek/e0b98c4627aa31a567e5"&gt;SAS_compare_dataset_variables · GitHub&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%macro compare_data(base=, compare=);&lt;/P&gt;&lt;P&gt;proc sql noprint;&lt;/P&gt;&lt;P&gt;&amp;nbsp; create table base_in as&lt;/P&gt;&lt;P&gt;&amp;nbsp; select name&lt;/P&gt;&lt;P&gt;&amp;nbsp; from sashelp.vcolumn&lt;/P&gt;&lt;P&gt;&amp;nbsp; where libname=upper(scan("&amp;amp;base", 1, "."))&lt;/P&gt;&lt;P&gt;&amp;nbsp; and memname=upper(scan("&amp;amp;base", 2, "."))&lt;/P&gt;&lt;P&gt;&amp;nbsp; order by varnum;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;P&gt;proc sql noprint;&lt;/P&gt;&lt;P&gt;&amp;nbsp; create table compare_in as&lt;/P&gt;&lt;P&gt;&amp;nbsp; select name&lt;/P&gt;&lt;P&gt;&amp;nbsp; from sashelp.vcolumn&lt;/P&gt;&lt;P&gt;&amp;nbsp; where libname=upper(scan("&amp;amp;compare", 1, "."))&lt;/P&gt;&lt;P&gt;&amp;nbsp; and memname=upper(scan("&amp;amp;compare", 2, "."))&lt;/P&gt;&lt;P&gt;&amp;nbsp; order by varnum;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;&amp;nbsp; create table comparison as&lt;/P&gt;&lt;P&gt;&amp;nbsp; select a.name as base_var, b.name as compare_var,&lt;/P&gt;&lt;P&gt;&amp;nbsp; case when missing(a.name) then catx("-", "Comparison dataset has extra variable", b.name)&lt;/P&gt;&lt;P&gt;&amp;nbsp; when missing(b.name) then catx("-", "Comparison dataset is missing variable", a.name)&lt;/P&gt;&lt;P&gt;&amp;nbsp; when a.name=b.name then "Variable in both datasets"&lt;/P&gt;&lt;P&gt;&amp;nbsp; else "CHECKME"&lt;/P&gt;&lt;P&gt;&amp;nbsp; end as comparison&lt;/P&gt;&lt;P&gt;&amp;nbsp; from base_in as a&lt;/P&gt;&lt;P&gt;&amp;nbsp; full join compare_in as b&lt;/P&gt;&lt;P&gt;&amp;nbsp; on 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;/* set comparison; */&lt;/P&gt;&lt;P&gt;/* if comparison not eq "Variable in both datasets" */&lt;/P&gt;&lt;P&gt;/*&amp;nbsp;&amp;nbsp; then put "ERROR:" comparison; */&lt;/P&gt;&lt;P&gt;/* run; */&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;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;/*example of calling macro*/&lt;/P&gt;&lt;P&gt;data class;&lt;/P&gt;&lt;P&gt;set sashelp.class;&lt;/P&gt;&lt;P&gt;bmi=(weight/(height**2))*703;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data class2;&lt;/P&gt;&lt;P&gt;set sashelp.class;&lt;/P&gt;&lt;P&gt;weight_kgs=weight*0.453592;&lt;/P&gt;&lt;P&gt;height_cm=height*2.54;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;%compare_data(base=work.class2, compare=work.class);&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 05 Aug 2015 01:34:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Merge-of-two-dataset-with-keeping-the-orders/m-p/216410#M53267</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2015-08-05T01:34:11Z</dc:date>
    </item>
    <item>
      <title>Re: Merge of two dataset with keeping the orders</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Merge-of-two-dataset-with-keeping-the-orders/m-p/216411#M53268</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If you really need this, start the data step by reading the dataset structures in the wanted order.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data WANT;&lt;/P&gt;&lt;P&gt;&amp;nbsp; if 0 then set DS2(keep= id&amp;nbsp; id_sub fname&amp;nbsp; lname&amp;nbsp; maintest1&amp;nbsp; maintest2&amp;nbsp; maintest2_2&amp;nbsp; subtest1);&lt;/P&gt;&lt;P&gt;&amp;nbsp; if 0 then set DS1(keep= subtest2);&lt;/P&gt;&lt;P&gt;&amp;nbsp; if 0 then set DS2(keep= date1&amp;nbsp; date1_sub);&lt;/P&gt;&lt;P&gt;&amp;nbsp; merge DS1 DS2;&lt;/P&gt;&lt;P&gt;...&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 05 Aug 2015 03:11:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Merge-of-two-dataset-with-keeping-the-orders/m-p/216411#M53268</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2015-08-05T03:11:17Z</dc:date>
    </item>
    <item>
      <title>Re: Merge of two dataset with keeping the orders</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Merge-of-two-dataset-with-keeping-the-orders/m-p/216412#M53269</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Oh, then that is very simple:&lt;/P&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; create table WANT as&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; select&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; A.VARNUM as ORDER_IN_BASE,&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; B.VARNUM as ORDER_IN_COMPARE,&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; 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="WORK" and MEMNAME="DATASET1") A&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; full join&amp;nbsp;&amp;nbsp; (select * from SASHELP.VCOLUMN where LIBNAME="WORK" and MEMNAME="DATASET2") B&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; on&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; A.NAME=B.NAME&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; order by&amp;nbsp; COALESCE(A.NAME,B.NAME) /* note I have order by name here, you could do any combination of name and orders */;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 05 Aug 2015 08:31:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Merge-of-two-dataset-with-keeping-the-orders/m-p/216412#M53269</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2015-08-05T08:31:07Z</dc:date>
    </item>
    <item>
      <title>Re: Merge of two dataset with keeping the orders</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Merge-of-two-dataset-with-keeping-the-orders/m-p/216413#M53270</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you for answer.&lt;/P&gt;&lt;P&gt;But i posted this because it's difficult to do with keeping varnum order.&lt;/P&gt;&lt;P&gt;If it exists the same valiable name in both dataset, output&amp;nbsp; this valiable name&amp;nbsp; by varnum order.&lt;/P&gt;&lt;P&gt;If it exists the valiable name in one side dataset, output the valiable name between neighborhood same valiable name with keeping varnum order.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 05 Aug 2015 09:04:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Merge-of-two-dataset-with-keeping-the-orders/m-p/216413#M53270</guid>
      <dc:creator>Hoz</dc:creator>
      <dc:date>2015-08-05T09:04:05Z</dc:date>
    </item>
    <item>
      <title>Re: Merge of two dataset with keeping the orders</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Merge-of-two-dataset-with-keeping-the-orders/m-p/216414#M53271</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Yes, but that is because the order you are thinking of is not a *logical* order.&amp;nbsp; Say you have:&lt;/P&gt;&lt;P&gt;1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; abc&lt;/P&gt;&lt;P&gt;2&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; def&lt;/P&gt;&lt;P&gt;3&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; efg&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;and &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; efg&lt;/P&gt;&lt;P&gt;2&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; abc&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What order should efg appear at?&amp;nbsp; What about abc, it is order 2 in the second example, but 1 in the first, the two merge but don't have the same order.&amp;nbsp; What I would suggest is that you think of the logical order for display, something you can put in a proc sort.&amp;nbsp; Alternatively have a look at the specifications, that should be your base, i.e. if the specs state: 1=abc, 2=def... then you can code that in and then merge the two sets of variables to that as you then have a predefined list.&amp;nbsp; If you haven't got specs, well...&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 05 Aug 2015 09:18:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Merge-of-two-dataset-with-keeping-the-orders/m-p/216414#M53271</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2015-08-05T09:18:21Z</dc:date>
    </item>
  </channel>
</rss>

