<?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: Create table statement overwritting first table in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Create-table-statement-overwritting-first-table/m-p/431759#M106845</link>
    <description>&lt;P&gt;Works as designed and documented. Use a new name if you don't want to overwrite the dataset.&lt;/P&gt;</description>
    <pubDate>Mon, 29 Jan 2018 12:32:28 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2018-01-29T12:32:28Z</dc:date>
    <item>
      <title>Create table statement overwritting first table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-table-statement-overwritting-first-table/m-p/431755#M106844</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql; &lt;BR /&gt;create table fruit &lt;BR /&gt;(&lt;BR /&gt;name VARCHAR(20), &lt;BR /&gt;owner VARCHAR(20), &lt;BR /&gt;species VARCHAR(20), &lt;BR /&gt;sex CHAR(1), &lt;BR /&gt;birth DATE &lt;BR /&gt;)&lt;BR /&gt;; &lt;BR /&gt;&lt;BR /&gt;quit;

proc sql; &lt;BR /&gt;create table fruit &lt;BR /&gt;(&lt;BR /&gt;species VARCHAR(20), &lt;BR /&gt;sex CHAR(1), &lt;BR /&gt;birth DATE &lt;BR /&gt;) &lt;BR /&gt;;&lt;BR /&gt;&lt;BR /&gt;quit;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to create table by CREATE TABLE sql statement. but it is not checking the table name weather there is another table or not. it is just over writing the existing table. could you please help?&lt;/P&gt;</description>
      <pubDate>Mon, 29 Jan 2018 12:27:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-table-statement-overwritting-first-table/m-p/431755#M106844</guid>
      <dc:creator>rashid3m0</dc:creator>
      <dc:date>2018-01-29T12:27:50Z</dc:date>
    </item>
    <item>
      <title>Re: Create table statement overwritting first table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-table-statement-overwritting-first-table/m-p/431759#M106845</link>
      <description>&lt;P&gt;Works as designed and documented. Use a new name if you don't want to overwrite the dataset.&lt;/P&gt;</description>
      <pubDate>Mon, 29 Jan 2018 12:32:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-table-statement-overwritting-first-table/m-p/431759#M106845</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-01-29T12:32:28Z</dc:date>
    </item>
    <item>
      <title>Re: Create table statement overwritting first table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-table-statement-overwritting-first-table/m-p/431772#M106848</link>
      <description>&lt;P&gt;Thanks for your suggestion. I can do that. But I don't want to overwrite by mistake. For example MySQL support as follows to prevent duplication of table name&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;CREAT TABLE IF NOT EXISTS fruit&lt;/P&gt;&lt;P&gt;(&lt;/P&gt;&lt;P&gt;name varchar(20),&lt;/P&gt;&lt;P&gt;)&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am looing for as describe above.&lt;/P&gt;</description>
      <pubDate>Mon, 29 Jan 2018 13:13:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-table-statement-overwritting-first-table/m-p/431772#M106848</guid>
      <dc:creator>rashid3m0</dc:creator>
      <dc:date>2018-01-29T13:13:29Z</dc:date>
    </item>
    <item>
      <title>Re: Create table statement overwritting first table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-table-statement-overwritting-first-table/m-p/431780#M106849</link>
      <description>&lt;P&gt;The question really is what is it your trying to do which would require such a thing?&amp;nbsp; Lets put it another way, you have written code before this part which does some work, so why do you not know if there will be some output from this code you created?&amp;nbsp; There are only two circumstances where you would need to create an empty table (and neither would care if the file already exists):&lt;/P&gt;
&lt;P&gt;You want to create template to ensure an output table is as you expect it&lt;/P&gt;
&lt;P&gt;You are going to use SQL syntax and insert data into the empty table&lt;/P&gt;
&lt;P&gt;So at no point would you need such a syntax.&amp;nbsp; I suspect your trying to do things using the thinking from another system, rather than using SAS methodology to do your logic.&amp;nbsp; Perhaps explain what it is your doing, providing explanations would help.&lt;/P&gt;</description>
      <pubDate>Mon, 29 Jan 2018 13:59:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-table-statement-overwritting-first-table/m-p/431780#M106849</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2018-01-29T13:59:09Z</dc:date>
    </item>
    <item>
      <title>Re: Create table statement overwritting first table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-table-statement-overwritting-first-table/m-p/431787#M106850</link>
      <description>&lt;P&gt;If you need to find out if a table already exists, SAS provides the exist() datastep function. Use it to set a macro variable, and you can then run code conditionally depending on that.&lt;/P&gt;</description>
      <pubDate>Mon, 29 Jan 2018 14:33:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-table-statement-overwritting-first-table/m-p/431787#M106850</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-01-29T14:33:19Z</dc:date>
    </item>
    <item>
      <title>Re: Create table statement overwritting first table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-table-statement-overwritting-first-table/m-p/431841#M106862</link>
      <description>&lt;P&gt;SAS has the REPLACE/NOREPLACE option.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you want a warning before you replace any table or a requirement to delete tables before replacing switch your option to NOREPLACE.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can also set&amp;nbsp;a password on a data set to prevent overwriting using PROC DATASETS.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;option noreplace;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 29 Jan 2018 16:32:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-table-statement-overwritting-first-table/m-p/431841#M106862</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-01-29T16:32:25Z</dc:date>
    </item>
    <item>
      <title>Re: Create table statement overwritting first table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-table-statement-overwritting-first-table/m-p/431959#M106904</link>
      <description>&lt;P&gt;Sometimes, doing simple things is complicated in SAS. Using SQL, you could do:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro createFruit;
proc sql noprint;
select count(*) into :cmd 
from dictionary.tables
where libname="WORK" and upcase(memname) = "FRUIT";
%if not &amp;amp;cmd %then %do;
create table fruit (name char(20));
%end;
quit;
%mend createFruit;
%createFruit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Note that &lt;STRONG&gt;option noreplace&lt;/STRONG&gt; has no effect in the WORK Library.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 29 Jan 2018 20:34:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-table-statement-overwritting-first-table/m-p/431959#M106904</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2018-01-29T20:34:33Z</dc:date>
    </item>
  </channel>
</rss>

