<?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 and proc sql in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Merge-and-proc-sql/m-p/615349#M76962</link>
    <description>&lt;P&gt;Try this&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
	input name :$10.;
	datalines;
Ram
Seetha
Radha
Bheem
Arjun
Seetha
Raj
Ram
;
run;

data desired_output;
	input name :$10.;
	datalines;
Ram
Seetha
Radha
Bheem
Arjun
Raj
;
run;

data have_with_rownum;
	set have;
	rownum=_n_;
run;

proc sort data=have_with_rownum nodupkey out=dedup;
	by name;
run;

proc sort data=dedup out=want(keep=name);
	by rownum;
run;

/*Check that want=desired_output*/
proc compare base=desired_output compare=want;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Mon, 06 Jan 2020 14:11:53 GMT</pubDate>
    <dc:creator>unison</dc:creator>
    <dc:date>2020-01-06T14:11:53Z</dc:date>
    <item>
      <title>Merge and proc sql</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Merge-and-proc-sql/m-p/615281#M76954</link>
      <description>Difference between merge and proc sql</description>
      <pubDate>Mon, 06 Jan 2020 11:14:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Merge-and-proc-sql/m-p/615281#M76954</guid>
      <dc:creator>Pooja98</dc:creator>
      <dc:date>2020-01-06T11:14:06Z</dc:date>
    </item>
    <item>
      <title>Re: Merge and proc sql</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Merge-and-proc-sql/m-p/615287#M76955</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/305675"&gt;@Pooja98&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Both DATA step merges and PROC SQL joins enable to join two or more tables.&lt;/P&gt;
&lt;P&gt;Sometimes they can produce the same outputs.&lt;/P&gt;
&lt;P&gt;Here are some of the main differences:&lt;/P&gt;
&lt;P&gt;- contrary to DATA step merges, you don't need to sort your data when you use PROC SQL joins&lt;/P&gt;
&lt;P&gt;- you need to add a "create table xxx as" clause in the PROC SQL as the default output is a report&lt;/P&gt;
&lt;DIV class="page" title="Page 100"&gt;
&lt;DIV class="layoutArea"&gt;
&lt;DIV class="column"&gt;
&lt;P&gt;&lt;SPAN&gt;- common columns need to have the same name in a DATA step merge, which is not the case for PROC SQL.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;- PROC SQL does not overlay common columns by default -&amp;gt; you need to mention one explicitly in the select clause or use the COALESCE option&lt;/SPAN&gt;&lt;/P&gt;
&lt;DIV class="page" title="Page 103"&gt;
&lt;DIV class="section"&gt;
&lt;DIV class="layoutArea"&gt;
&lt;DIV class="column"&gt;
&lt;P&gt;&lt;SPAN&gt;- Another thing is that you can use another operator that = in you joint expression.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;- in case your input datasets have not a unique "key" for merging, it is useful to use PROC SQL as by design, it will create the&amp;nbsp;Cartesian product of input datasets as the result and then delete observations that don't meet the join expression condition(s) -&amp;gt; so depending on the method you&amp;nbsp;choose, you can have different results.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;PROC SQL can be also more efficient, especially if you have large datasets.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Hope this help!&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Best,&lt;/SPAN&gt;&lt;/P&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;</description>
      <pubDate>Mon, 06 Jan 2020 11:44:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Merge-and-proc-sql/m-p/615287#M76955</guid>
      <dc:creator>ed_sas_member</dc:creator>
      <dc:date>2020-01-06T11:44:30Z</dc:date>
    </item>
    <item>
      <title>Re: Merge and proc sql</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Merge-and-proc-sql/m-p/615313#M76956</link>
      <description>Thanks a lot!!</description>
      <pubDate>Mon, 06 Jan 2020 12:53:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Merge-and-proc-sql/m-p/615313#M76956</guid>
      <dc:creator>Pooja98</dc:creator>
      <dc:date>2020-01-06T12:53:19Z</dc:date>
    </item>
    <item>
      <title>Re: Merge and proc sql</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Merge-and-proc-sql/m-p/615314#M76957</link>
      <description>What is %include statement??</description>
      <pubDate>Mon, 06 Jan 2020 12:53:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Merge-and-proc-sql/m-p/615314#M76957</guid>
      <dc:creator>Pooja98</dc:creator>
      <dc:date>2020-01-06T12:53:43Z</dc:date>
    </item>
    <item>
      <title>Re: Merge and proc sql</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Merge-and-proc-sql/m-p/615316#M76958</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/305675"&gt;@Pooja98&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The %include statement allow you to bring a SAS program stored in an external file in your current program.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here is the documentation about this statement:&amp;nbsp;&lt;A href="http://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a000214504.htm" target="_self"&gt;http://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a000214504.htm&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 06 Jan 2020 12:55:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Merge-and-proc-sql/m-p/615316#M76958</guid>
      <dc:creator>ed_sas_member</dc:creator>
      <dc:date>2020-01-06T12:55:54Z</dc:date>
    </item>
    <item>
      <title>Re: Merge and proc sql</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Merge-and-proc-sql/m-p/615318#M76960</link>
      <description>&lt;P&gt;Long-time SAS user and community member&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/201950"&gt;@Rick_Andrews&lt;/a&gt;&amp;nbsp;summarizes the differences and techniques in this article:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;&lt;A href="https://communities.sas.com/t5/SAS-Communities-Library/Traditional-SAS-Programming-versus-SQL/ta-p/451481" target="_self"&gt;Traditional SAS Programming versus PROC SQL&lt;/A&gt;&lt;/LI&gt;
&lt;/UL&gt;</description>
      <pubDate>Mon, 06 Jan 2020 12:58:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Merge-and-proc-sql/m-p/615318#M76960</guid>
      <dc:creator>ChrisHemedinger</dc:creator>
      <dc:date>2020-01-06T12:58:39Z</dc:date>
    </item>
    <item>
      <title>Re: Merge and proc sql</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Merge-and-proc-sql/m-p/615326#M76961</link>
      <description>Hi, can anyone help me with this???&lt;BR /&gt;I need to remove duplicates and at the same time i don't want to change my order&lt;BR /&gt;&lt;BR /&gt;Name&lt;BR /&gt;&lt;BR /&gt;Ram&lt;BR /&gt;Seetha&lt;BR /&gt;Radha&lt;BR /&gt;Bheem&lt;BR /&gt;Arjun&lt;BR /&gt;Seetha&lt;BR /&gt;Raj&lt;BR /&gt;Ram&lt;BR /&gt;&lt;BR /&gt;The output should be :&lt;BR /&gt;&lt;BR /&gt;Ram&lt;BR /&gt;Seetha&lt;BR /&gt;Radha&lt;BR /&gt;Bheem&lt;BR /&gt;Arjun&lt;BR /&gt;Raj&lt;BR /&gt;&lt;BR /&gt;I tried both nodupkey and distinct, i got the results but name variable displaying in ascending order</description>
      <pubDate>Mon, 06 Jan 2020 13:21:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Merge-and-proc-sql/m-p/615326#M76961</guid>
      <dc:creator>Pooja98</dc:creator>
      <dc:date>2020-01-06T13:21:59Z</dc:date>
    </item>
    <item>
      <title>Re: Merge and proc sql</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Merge-and-proc-sql/m-p/615349#M76962</link>
      <description>&lt;P&gt;Try this&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
	input name :$10.;
	datalines;
Ram
Seetha
Radha
Bheem
Arjun
Seetha
Raj
Ram
;
run;

data desired_output;
	input name :$10.;
	datalines;
Ram
Seetha
Radha
Bheem
Arjun
Raj
;
run;

data have_with_rownum;
	set have;
	rownum=_n_;
run;

proc sort data=have_with_rownum nodupkey out=dedup;
	by name;
run;

proc sort data=dedup out=want(keep=name);
	by rownum;
run;

/*Check that want=desired_output*/
proc compare base=desired_output compare=want;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 06 Jan 2020 14:11:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Merge-and-proc-sql/m-p/615349#M76962</guid>
      <dc:creator>unison</dc:creator>
      <dc:date>2020-01-06T14:11:53Z</dc:date>
    </item>
    <item>
      <title>Re: Merge and proc sql</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Merge-and-proc-sql/m-p/615658#M76985</link>
      <description />
      <pubDate>Tue, 07 Jan 2020 13:30:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Merge-and-proc-sql/m-p/615658#M76985</guid>
      <dc:creator>Pooja98</dc:creator>
      <dc:date>2020-01-07T13:30:50Z</dc:date>
    </item>
  </channel>
</rss>

