<?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: use proc sql to rewrite code with &amp;quot;data set&amp;quot; in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/use-proc-sql-to-rewrite-code-with-quot-data-set-quot/m-p/290997#M60277</link>
    <description>&lt;P&gt;As mentioned by&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13604"&gt;@Doc_Duke﻿&lt;/a&gt;, you are not sorting the data nor merging it. &amp;nbsp;The set statement in the given example will take all the data from table1, then below that will set all the data from table2. &amp;nbsp;You can use the proc append procedure to achieve the same thing (and it would be quicker):&lt;/P&gt;
&lt;P&gt;&lt;A href="http://support.sas.com/documentation/cdl/en/proc/61895/HTML/default/viewer.htm#a000070936.htm" target="_blank"&gt;http://support.sas.com/documentation/cdl/en/proc/61895/HTML/default/viewer.htm#a000070936.htm&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But if your fixed on SQL, you won't get much speed gains, you would use union command - note columns have to all be the same:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;proc sql;
  create table WANT as
  select   *
  from     (select *,"From Table1" as INTBL from TABLE1) 
  union all
  select   *
  from     (select *,"From Table2" as INTBL from TABLE2);
quit;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 11 Aug 2016 14:55:33 GMT</pubDate>
    <dc:creator>RW9</dc:creator>
    <dc:date>2016-08-11T14:55:33Z</dc:date>
    <item>
      <title>use proc sql to rewrite code with "data set"</title>
      <link>https://communities.sas.com/t5/SAS-Programming/use-proc-sql-to-rewrite-code-with-quot-data-set-quot/m-p/290985#M60275</link>
      <description>&lt;P&gt;I want to merge two datasets. I previously needed to sort them first, them&lt;/P&gt;
&lt;P&gt;data want&lt;/P&gt;
&lt;P&gt;set have1 have2&lt;/P&gt;
&lt;P&gt;indsname=ind&lt;/P&gt;
&lt;P&gt;contributing_tbl=ind;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In this way, I get a new variable indicating where it is originally from&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;However, use "set" is too slow and needs to sort first, which takes more time, I want to change to use proc sql;&lt;/P&gt;
&lt;P&gt;however, I need advice from you how to have a simiar statement that adds a column that indicting where it is orginally from have1, or have2,&lt;/P&gt;
&lt;P&gt;would you please advice? Thanks.&lt;/P&gt;</description>
      <pubDate>Thu, 11 Aug 2016 14:22:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/use-proc-sql-to-rewrite-code-with-quot-data-set-quot/m-p/290985#M60275</guid>
      <dc:creator>Bal23</dc:creator>
      <dc:date>2016-08-11T14:22:54Z</dc:date>
    </item>
    <item>
      <title>Re: use proc sql to rewrite code with "data set"</title>
      <link>https://communities.sas.com/t5/SAS-Programming/use-proc-sql-to-rewrite-code-with-quot-data-set-quot/m-p/290989#M60276</link>
      <description>&lt;P&gt;The syntax you have is not technically correct (missing multiple semi-colons), so it is hard to understand what you are really trying to do.&amp;nbsp; The DATA step, as stated, does not require the data sets to be sorted; is there a BY statement missing?&lt;/P&gt;</description>
      <pubDate>Thu, 11 Aug 2016 14:34:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/use-proc-sql-to-rewrite-code-with-quot-data-set-quot/m-p/290989#M60276</guid>
      <dc:creator>Doc_Duke</dc:creator>
      <dc:date>2016-08-11T14:34:48Z</dc:date>
    </item>
    <item>
      <title>Re: use proc sql to rewrite code with "data set"</title>
      <link>https://communities.sas.com/t5/SAS-Programming/use-proc-sql-to-rewrite-code-with-quot-data-set-quot/m-p/290997#M60277</link>
      <description>&lt;P&gt;As mentioned by&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13604"&gt;@Doc_Duke﻿&lt;/a&gt;, you are not sorting the data nor merging it. &amp;nbsp;The set statement in the given example will take all the data from table1, then below that will set all the data from table2. &amp;nbsp;You can use the proc append procedure to achieve the same thing (and it would be quicker):&lt;/P&gt;
&lt;P&gt;&lt;A href="http://support.sas.com/documentation/cdl/en/proc/61895/HTML/default/viewer.htm#a000070936.htm" target="_blank"&gt;http://support.sas.com/documentation/cdl/en/proc/61895/HTML/default/viewer.htm#a000070936.htm&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But if your fixed on SQL, you won't get much speed gains, you would use union command - note columns have to all be the same:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;proc sql;
  create table WANT as
  select   *
  from     (select *,"From Table1" as INTBL from TABLE1) 
  union all
  select   *
  from     (select *,"From Table2" as INTBL from TABLE2);
quit;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 11 Aug 2016 14:55:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/use-proc-sql-to-rewrite-code-with-quot-data-set-quot/m-p/290997#M60277</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2016-08-11T14:55:33Z</dc:date>
    </item>
    <item>
      <title>Re: use proc sql to rewrite code with "data set"</title>
      <link>https://communities.sas.com/t5/SAS-Programming/use-proc-sql-to-rewrite-code-with-quot-data-set-quot/m-p/290998#M60278</link>
      <description>You are confusing merge with append...?&lt;BR /&gt;Your code does append data and then there is no (technical) reason to pre sort the data.&lt;BR /&gt;And what is slow?&lt;BR /&gt;Show a log of the performance, and tell us what your requirement is.&lt;BR /&gt;&lt;BR /&gt;If we ignore your code a talk about merge, yes, in SQL you don't need to pre sort the data. But SQL usually does that for you behind the scenes, and that isn't necessarily faster (unless you have lots of RAM).</description>
      <pubDate>Thu, 11 Aug 2016 14:56:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/use-proc-sql-to-rewrite-code-with-quot-data-set-quot/m-p/290998#M60278</guid>
      <dc:creator>LinusH</dc:creator>
      <dc:date>2016-08-11T14:56:00Z</dc:date>
    </item>
    <item>
      <title>Re: use proc sql to rewrite code with "data set"</title>
      <link>https://communities.sas.com/t5/SAS-Programming/use-proc-sql-to-rewrite-code-with-quot-data-set-quot/m-p/291006#M60280</link>
      <description>&lt;P&gt;Thank you!&lt;/P&gt;</description>
      <pubDate>Thu, 11 Aug 2016 15:19:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/use-proc-sql-to-rewrite-code-with-quot-data-set-quot/m-p/291006#M60280</guid>
      <dc:creator>Bal23</dc:creator>
      <dc:date>2016-08-11T15:19:02Z</dc:date>
    </item>
    <item>
      <title>Re: use proc sql to rewrite code with "data set"</title>
      <link>https://communities.sas.com/t5/SAS-Programming/use-proc-sql-to-rewrite-code-with-quot-data-set-quot/m-p/291007#M60281</link>
      <description>&lt;P&gt;My actual problem is,&lt;/P&gt;
&lt;P&gt;combine first two into class I; then combine the last two into class II; then combine these two classes into one big dataset;&lt;/P&gt;
&lt;P&gt;can you give advice how to do it with one proc sql step?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Thu, 11 Aug 2016 15:21:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/use-proc-sql-to-rewrite-code-with-quot-data-set-quot/m-p/291007#M60281</guid>
      <dc:creator>Bal23</dc:creator>
      <dc:date>2016-08-11T15:21:04Z</dc:date>
    </item>
  </channel>
</rss>

