<?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: insert into vs. proc append when first dataset does not exist in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/insert-into-vs-proc-append-when-first-dataset-does-not-exist/m-p/653055#M196133</link>
    <description>Macros are (mostly) text generators.They can generate HQL or anything you want. Since you ask about proc append, I assume you are running SAS code. Therefore you can run macro code too. &lt;BR /&gt;</description>
    <pubDate>Thu, 04 Jun 2020 03:52:11 GMT</pubDate>
    <dc:creator>ChrisNZ</dc:creator>
    <dc:date>2020-06-04T03:52:11Z</dc:date>
    <item>
      <title>insert into vs. proc append when first dataset does not exist</title>
      <link>https://communities.sas.com/t5/SAS-Programming/insert-into-vs-proc-append-when-first-dataset-does-not-exist/m-p/653037#M196122</link>
      <description>&lt;P&gt;Proc Append works when the base dataset does not exist, does Proc Sql insert into work in this situation?&lt;/P&gt;</description>
      <pubDate>Thu, 04 Jun 2020 01:23:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/insert-into-vs-proc-append-when-first-dataset-does-not-exist/m-p/653037#M196122</guid>
      <dc:creator>ARC2</dc:creator>
      <dc:date>2020-06-04T01:23:31Z</dc:date>
    </item>
    <item>
      <title>Re: insert into vs. proc append when first dataset does not exist</title>
      <link>https://communities.sas.com/t5/SAS-Programming/insert-into-vs-proc-append-when-first-dataset-does-not-exist/m-p/653040#M196123</link>
      <description>&lt;P&gt;No, you'll get an error. SQL requires the table to pre-exist.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
insert into class
select * from sashelp.class;
quit;


data class;
set sashelp.class (obs=0);
run;


proc sql;
insert into class
select * from sashelp.class;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Log:&lt;/P&gt;
&lt;PRE&gt;68         
 69         proc sql;
 70         insert into class
 71         select * from sashelp.class;
 ERROR: File WORK.CLASS.DATA does not exist.
 NOTE: PROC SQL set option NOEXEC and will continue to check the syntax of statements.
 72         quit;
 NOTE: The SAS System stopped processing this step because of errors.
 NOTE: PROCEDURE SQL used (Total process time):
       real time           0.00 seconds
       user cpu time       0.00 seconds
       system cpu time     0.00 seconds
       memory              331.87k
       OS Memory           23712.00k
       Timestamp           2020-06-04 01:45:24 AM
       Step Count                        30  Switch Count  0
       Page Faults                       0
       Page Reclaims                     16
       Page Swaps                        0
       Voluntary Context Switches        0
       Involuntary Context Switches      0
       Block Input Operations            0
       Block Output Operations           0
       
 73         
 74         
 
 
 75         data class;
 76         set sashelp.class (obs=0);
 77         run;
 
 NOTE: There were 0 observations read from the data set SASHELP.CLASS.
 NOTE: The data set WORK.CLASS has 0 observations and 5 variables.
 NOTE: DATA statement used (Total process time):
       real time           0.00 seconds
       user cpu time       0.01 seconds
       system cpu time     0.00 seconds
       memory              830.50k
       OS Memory           24228.00k
       Timestamp           2020-06-04 01:45:24 AM
       Step Count                        31  Switch Count  2
       Page Faults                       0
       Page Reclaims                     165
       Page Swaps                        0
       Voluntary Context Switches        9
       Involuntary Context Switches      0
       Block Input Operations            0
       Block Output Operations           264
       
 
 78         
 79         
 80         proc sql;
 81         insert into class
 82         select * from sashelp.class;
 NOTE: 19 rows were inserted into WORK.CLASS.
 
 83         quit;
 NOTE: PROCEDURE SQL used (Total process time):
       real time           0.00 seconds
       user cpu time       0.00 seconds
       system cpu time     0.00 seconds
       memory              5741.34k
       OS Memory           29352.00k
       Timestamp           2020-06-04 01:45:24 AM
       Step Count                        32  Switch Count  0
       Page Faults                       0
       Page Reclaims                     98
       Page Swaps                        0
       Voluntary Context Switches        0
       Involuntary Context Switches      0
       Block Input Operations            0
       Block Output Operations           0&lt;/PRE&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/259289"&gt;@ARC2&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Proc Append works when the base dataset does not exist, does Proc Sql insert into work in this situation?&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 04 Jun 2020 01:46:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/insert-into-vs-proc-append-when-first-dataset-does-not-exist/m-p/653040#M196123</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2020-06-04T01:46:40Z</dc:date>
    </item>
    <item>
      <title>Re: insert into vs. proc append when first dataset does not exist</title>
      <link>https://communities.sas.com/t5/SAS-Programming/insert-into-vs-proc-append-when-first-dataset-does-not-exist/m-p/653042#M196124</link>
      <description>&lt;P&gt;If you need to only use SQL:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
  %sysfunc(ifc(%sysfunc(exist(CLASS))
              ,insert into CLASS
              ,create table CLASS as
  )) 
  select * FROM SASHELP.CLASS;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Note that proc append is probably much faster than SQL inserts.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 04 Jun 2020 02:26:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/insert-into-vs-proc-append-when-first-dataset-does-not-exist/m-p/653042#M196124</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2020-06-04T02:26:44Z</dc:date>
    </item>
    <item>
      <title>Re: insert into vs. proc append when first dataset does not exist</title>
      <link>https://communities.sas.com/t5/SAS-Programming/insert-into-vs-proc-append-when-first-dataset-does-not-exist/m-p/653054#M196132</link>
      <description>&lt;P&gt;That is the answer to the question I asked, but I need for it to work in hiveql and all the macro stuff won't work there.&amp;nbsp; Still, thanks!&lt;/P&gt;</description>
      <pubDate>Thu, 04 Jun 2020 03:46:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/insert-into-vs-proc-append-when-first-dataset-does-not-exist/m-p/653054#M196132</guid>
      <dc:creator>ARC2</dc:creator>
      <dc:date>2020-06-04T03:46:49Z</dc:date>
    </item>
    <item>
      <title>Re: insert into vs. proc append when first dataset does not exist</title>
      <link>https://communities.sas.com/t5/SAS-Programming/insert-into-vs-proc-append-when-first-dataset-does-not-exist/m-p/653055#M196133</link>
      <description>Macros are (mostly) text generators.They can generate HQL or anything you want. Since you ask about proc append, I assume you are running SAS code. Therefore you can run macro code too. &lt;BR /&gt;</description>
      <pubDate>Thu, 04 Jun 2020 03:52:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/insert-into-vs-proc-append-when-first-dataset-does-not-exist/m-p/653055#M196133</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2020-06-04T03:52:11Z</dc:date>
    </item>
    <item>
      <title>Re: insert into vs. proc append when first dataset does not exist</title>
      <link>https://communities.sas.com/t5/SAS-Programming/insert-into-vs-proc-append-when-first-dataset-does-not-exist/m-p/653059#M196134</link>
      <description>&lt;P&gt;If you want to code everything in Hive QL then just execute a &lt;A href="https://cwiki.apache.org/confluence/display/Hive/LanguageManual+DDL#LanguageManualDDL-CreateTableCreate/Drop/TruncateTable" target="_self"&gt;&lt;EM&gt;Create Table IF NOT EXISTS&lt;/EM&gt;&lt;/A&gt; before your&lt;EM&gt; Insert&lt;/EM&gt;.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Btw: I believe if the source and target table are both in Hadoop (or similar) then Proc Append will generate code that executes in-database.&lt;/P&gt;
&lt;P&gt;I'm less convinced that if the target (base) table doesn't exist SAS would create it with the exact same data types like the source table - but it's something worth testing as if it does then using Proc Append would be the easiest way to code what you're after - unless you need more control like loading into a specific partition or the like.&lt;/P&gt;</description>
      <pubDate>Thu, 04 Jun 2020 04:43:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/insert-into-vs-proc-append-when-first-dataset-does-not-exist/m-p/653059#M196134</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2020-06-04T04:43:50Z</dc:date>
    </item>
    <item>
      <title>Re: insert into vs. proc append when first dataset does not exist</title>
      <link>https://communities.sas.com/t5/SAS-Programming/insert-into-vs-proc-append-when-first-dataset-does-not-exist/m-p/653458#M196294</link>
      <description>&lt;P&gt;I want to loop through and create the dataset in the first pass through the loop and then keep adding to it in subsequent passes.&amp;nbsp; It will exist in the second pass so this won't work for me.&amp;nbsp; Great idea though, thanks.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 04 Jun 2020 23:37:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/insert-into-vs-proc-append-when-first-dataset-does-not-exist/m-p/653458#M196294</guid>
      <dc:creator>ARC2</dc:creator>
      <dc:date>2020-06-04T23:37:24Z</dc:date>
    </item>
    <item>
      <title>Re: insert into vs. proc append when first dataset does not exist</title>
      <link>https://communities.sas.com/t5/SAS-Programming/insert-into-vs-proc-append-when-first-dataset-does-not-exist/m-p/653490#M196299</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/259289"&gt;@ARC2&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I want to loop through and create the dataset in the first pass through the loop and then keep adding to it in subsequent passes.&amp;nbsp; It will exist in the second pass so this won't work for me.&amp;nbsp; Great idea though, thanks.&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Not sure that I understand. Are we now dealing with a table in Hadoop or a SAS dataset? If it's a table in Hadoop then because of IF NOT EXISTS you can call the Create Table statement as many times as you wish. It will only ever actually execute and create the table if it doesn't exist already.&lt;/P&gt;
&lt;P&gt;Not sure where your loop comes comes into the picture - are you executing a separate insert statement row by row? If so then I'd certainly would execute the Create Table before such a loop - but it should even work if executed within the loop.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 05 Jun 2020 03:13:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/insert-into-vs-proc-append-when-first-dataset-does-not-exist/m-p/653490#M196299</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2020-06-05T03:13:29Z</dc:date>
    </item>
    <item>
      <title>Re: insert into vs. proc append when first dataset does not exist</title>
      <link>https://communities.sas.com/t5/SAS-Programming/insert-into-vs-proc-append-when-first-dataset-does-not-exist/m-p/653496#M196301</link>
      <description>&lt;P&gt;Everything is in Hadoop.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Say, I create data set 1, then add it data set all (which doesn't exist at this point), then I create data set 2, then add it to all (which now exists), then create dataset 3 and add it to dataset all,&amp;nbsp; and so on.&amp;nbsp; I know how to do this with proc append, but not with sql.&amp;nbsp; Will the code above do this? &amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 05 Jun 2020 03:53:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/insert-into-vs-proc-append-when-first-dataset-does-not-exist/m-p/653496#M196301</guid>
      <dc:creator>ARC2</dc:creator>
      <dc:date>2020-06-05T03:53:27Z</dc:date>
    </item>
    <item>
      <title>Re: insert into vs. proc append when first dataset does not exist</title>
      <link>https://communities.sas.com/t5/SAS-Programming/insert-into-vs-proc-append-when-first-dataset-does-not-exist/m-p/653499#M196303</link>
      <description>&lt;P&gt;On this very high level: Yes, it does.&lt;/P&gt;
&lt;P&gt;You're now again using the term "dataset". This term is used for SAS tables but not for Hive tables.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It's may be worth if you explain us a bit more in detail what you have and what you need. Also tell us always where the data source and target is stored (SAS or Hadoop) and what SAS client you're using to implement ("loop" makes me think it could be DIS).&lt;/P&gt;</description>
      <pubDate>Fri, 05 Jun 2020 04:08:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/insert-into-vs-proc-append-when-first-dataset-does-not-exist/m-p/653499#M196303</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2020-06-05T04:08:59Z</dc:date>
    </item>
  </channel>
</rss>

