<?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: PROC SQL CREATE TABLE question in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/PROC-SQL-CREATE-TABLE-question/m-p/22675#M4973</link>
    <description>I think the DDL to create the table happens before the query is actually performed.  For some codes, that's a shortcut to duplicate the table structure without copying data.  For example, if you say&lt;BR /&gt;
create table TABA as select * from TABB where 1=2;&lt;BR /&gt;
&lt;BR /&gt;
You will get a copy of the table structure without any data.&lt;BR /&gt;
&lt;BR /&gt;
I would think you'll have to use macros to check and see if there are records that match your criteria and only then would you create the table.</description>
    <pubDate>Sat, 05 Mar 2011 13:09:05 GMT</pubDate>
    <dc:creator>DBailey</dc:creator>
    <dc:date>2011-03-05T13:09:05Z</dc:date>
    <item>
      <title>PROC SQL CREATE TABLE question</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/PROC-SQL-CREATE-TABLE-question/m-p/22673#M4971</link>
      <description>When using the code below it creates the table even if no records are returned. Is there a way to tell to to only create the table if records are returned as the result of the WHERE clause? I want to use the table creation itself as a trigger for other processes&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
PROC SQL;&lt;BR /&gt;
  CREATE TABLE work.STF_2001 AS SELECT &lt;BR /&gt;
  QUERY3723.Trigger &lt;BR /&gt;
 FROM WORK.QUERY3723 AS QUERY3723&lt;BR /&gt;
 WHERE QUERY3723.Trigger = 0;&lt;BR /&gt;
QUIT;</description>
      <pubDate>Fri, 04 Mar 2011 21:06:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/PROC-SQL-CREATE-TABLE-question/m-p/22673#M4971</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2011-03-04T21:06:23Z</dc:date>
    </item>
    <item>
      <title>Re: PROC SQL CREATE TABLE question</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/PROC-SQL-CREATE-TABLE-question/m-p/22674#M4972</link>
      <description>Hi Joel,&lt;BR /&gt;
&lt;BR /&gt;
I think you no need to mention Work library. If you dont save the dataset in permament library , default it will save it on work library.&lt;BR /&gt;
&lt;BR /&gt;
Try this,&lt;BR /&gt;
Proc Sql;&lt;BR /&gt;
create table STF_2002 &lt;BR /&gt;
as                                                                                                             &lt;BR /&gt;
select Q.Trigger&lt;BR /&gt;
from QUERY3723 AS Q where Q.Trigger=0;&lt;BR /&gt;
Quit;&lt;BR /&gt;
&lt;BR /&gt;
Thanks,&lt;BR /&gt;
Raj</description>
      <pubDate>Fri, 04 Mar 2011 21:23:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/PROC-SQL-CREATE-TABLE-question/m-p/22674#M4972</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2011-03-04T21:23:59Z</dc:date>
    </item>
    <item>
      <title>Re: PROC SQL CREATE TABLE question</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/PROC-SQL-CREATE-TABLE-question/m-p/22675#M4973</link>
      <description>I think the DDL to create the table happens before the query is actually performed.  For some codes, that's a shortcut to duplicate the table structure without copying data.  For example, if you say&lt;BR /&gt;
create table TABA as select * from TABB where 1=2;&lt;BR /&gt;
&lt;BR /&gt;
You will get a copy of the table structure without any data.&lt;BR /&gt;
&lt;BR /&gt;
I would think you'll have to use macros to check and see if there are records that match your criteria and only then would you create the table.</description>
      <pubDate>Sat, 05 Mar 2011 13:09:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/PROC-SQL-CREATE-TABLE-question/m-p/22675#M4973</guid>
      <dc:creator>DBailey</dc:creator>
      <dc:date>2011-03-05T13:09:05Z</dc:date>
    </item>
    <item>
      <title>Re: PROC SQL CREATE TABLE question</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/PROC-SQL-CREATE-TABLE-question/m-p/22676#M4974</link>
      <description>that's what I was thinking - &lt;BR /&gt;
&lt;BR /&gt;
I don't need a specifically a proc SQL - &lt;BR /&gt;
&lt;BR /&gt;
a SAS data step would work as well - &lt;BR /&gt;
&lt;BR /&gt;
but what I need is a macro that checks the tabel for records - &lt;BR /&gt;
&lt;BR /&gt;
if there are some it creates TableA and if not TableB&lt;BR /&gt;
&lt;BR /&gt;
anyone have a sample macro that does that?</description>
      <pubDate>Sun, 06 Mar 2011 20:39:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/PROC-SQL-CREATE-TABLE-question/m-p/22676#M4974</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2011-03-06T20:39:15Z</dc:date>
    </item>
    <item>
      <title>Re: PROC SQL CREATE TABLE question</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/PROC-SQL-CREATE-TABLE-question/m-p/22677#M4975</link>
      <description>You could use something like:&lt;BR /&gt;
proc sql;&lt;BR /&gt;
&lt;BR /&gt;
%macro ConditionalCreate;&lt;BR /&gt;
&lt;BR /&gt;
select count(*) into: macrovar&lt;BR /&gt;
 from a&lt;BR /&gt;
 where b=c&lt;BR /&gt;
;&lt;BR /&gt;
quit;&lt;BR /&gt;
&lt;BR /&gt;
%if &amp;amp;macrovar ne 0 %then %do;&lt;BR /&gt;
&lt;BR /&gt;
proc sql;&lt;BR /&gt;
create table&lt;BR /&gt;
...&lt;BR /&gt;
&lt;BR /&gt;
;&lt;BR /&gt;
quit;&lt;BR /&gt;
%end;&lt;BR /&gt;
%mend ConditionalCreate;&lt;BR /&gt;
&lt;BR /&gt;
%ConditionalCreate;&lt;BR /&gt;
&lt;BR /&gt;
/Linus</description>
      <pubDate>Mon, 07 Mar 2011 13:32:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/PROC-SQL-CREATE-TABLE-question/m-p/22677#M4975</guid>
      <dc:creator>LinusH</dc:creator>
      <dc:date>2011-03-07T13:32:03Z</dc:date>
    </item>
    <item>
      <title>Re: PROC SQL CREATE TABLE question</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/PROC-SQL-CREATE-TABLE-question/m-p/22678#M4976</link>
      <description>Hi Linus&lt;BR /&gt;
&lt;BR /&gt;
Excellent worked perfectly!&lt;BR /&gt;
&lt;BR /&gt;
Thanks - Joel</description>
      <pubDate>Mon, 07 Mar 2011 16:46:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/PROC-SQL-CREATE-TABLE-question/m-p/22678#M4976</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2011-03-07T16:46:52Z</dc:date>
    </item>
  </channel>
</rss>

