<?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 Error: with table failure in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Proc-SQL-Error-with-table-failure/m-p/518428#M140311</link>
    <description>&lt;P&gt;This example is a bit of a simple one. There are some more complex SQL solutions that I had at the previous job that abused creating a series of cascading "with statements" to use some of the functionality that SQL has that SAS doesn't, mainly multiple data partitioning followed by additional selects.&lt;/P&gt;</description>
    <pubDate>Tue, 04 Dec 2018 14:55:47 GMT</pubDate>
    <dc:creator>ksnyder1986</dc:creator>
    <dc:date>2018-12-04T14:55:47Z</dc:date>
    <item>
      <title>Proc SQL Error: with table failure</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-SQL-Error-with-table-failure/m-p/518397#M140297</link>
      <description>&lt;P&gt;I have an odder error that I haven't ran into in the past. This has always worked for me in previous instances so the failure makes me wonder if it is a setting at my new job.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I attempted to run this code:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;	proc sql;
		connect to odbc (user="&amp;amp;ntuser." password="&amp;amp;ntpw." dsn=Server_Name connection=shared);

		create table End_Result as
		select * from connection to odbc
		(
                        with EOM_date as
                        (
                            select 
                                max(Prior_time_day_gen_id) as max_procdt 
                            from Business_Calander_Table 
                            where month(cast(prior_time_day_gen_id as date)) != month(cast(time_day_gen_id as date)) 
                            and cast(prior_time_day_gen_id as date) &amp;lt;= &amp;amp;start_db.
                        )

			select 
				a.*
			from 
				Data_Table a inner join Eom_Date
					on a.procdt = b.max_procdt
		);
quit;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I got the error:&lt;/P&gt;&lt;P&gt;ERROR: PROC SQL requires any created table to have at least 1 column.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If I run this code directly in the SQL Server it works just fine, and if I instead run the code below it works (this code takes the with statement and puts it as a sub-select instead:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;	proc sql;
		connect to odbc (user="&amp;amp;ntuser." password="&amp;amp;ntpw." dsn=Server_Name connection=shared);

		create table End_Result as
		select * from connection to odbc
		(
                        select 
				a.*
			from 
				Data_Table a 
                        inner join   (
                            select 
                                max(Prior_time_day_gen_id) as max_procdt 
                            from Business_Calander_Table 
                            where month(cast(prior_time_day_gen_id as date)) != month(cast(time_day_gen_id as date)) 
                            and cast(prior_time_day_gen_id as date) &amp;lt;= &amp;amp;start_db.
                        )
					on a.procdt = b.max_procdt
		);
quit;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any ideas on why it is failing on the with statement?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Using 9.4 on Windows 10. The server is a MS SQL Server.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 04 Dec 2018 14:16:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-SQL-Error-with-table-failure/m-p/518397#M140297</guid>
      <dc:creator>ksnyder1986</dc:creator>
      <dc:date>2018-12-04T14:16:07Z</dc:date>
    </item>
    <item>
      <title>Re: Proc SQL Error: with table failure</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-SQL-Error-with-table-failure/m-p/518418#M140306</link>
      <description>&lt;P&gt;The syntax with is not valid ANSI SQL, it is a database specific functionality.&amp;nbsp; hence it is not implemented in proc sql as that only implements ANSI SQL.&amp;nbsp; If you want to use that syntax, then you will need to use pass-through and send the code to the specific database for processing.&lt;/P&gt;</description>
      <pubDate>Tue, 04 Dec 2018 14:41:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-SQL-Error-with-table-failure/m-p/518418#M140306</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2018-12-04T14:41:28Z</dc:date>
    </item>
    <item>
      <title>Re: Proc SQL Error: with table failure</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-SQL-Error-with-table-failure/m-p/518422#M140307</link>
      <description>&lt;P&gt;I'm sorry, but isn't this a pass-through syntax? I am using an odbc connection to the server. Perhaps I misunderstand exactly what a pass-through means.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Also, this syntax worked correctly at my previous job in the same type of statement.&lt;/P&gt;</description>
      <pubDate>Tue, 04 Dec 2018 14:45:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-SQL-Error-with-table-failure/m-p/518422#M140307</guid>
      <dc:creator>ksnyder1986</dc:creator>
      <dc:date>2018-12-04T14:45:03Z</dc:date>
    </item>
    <item>
      <title>Re: Proc SQL Error: with table failure</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-SQL-Error-with-table-failure/m-p/518427#M140310</link>
      <description>&lt;P&gt;True, you are using pass-through there, but not in a way that SAS understands as it is database specific.&amp;nbsp; From what I can tell from the with syntax, it doesn't create or return a table, but more of a reference to one.&amp;nbsp; SAS expects a table back from the statement.&amp;nbsp; What is the purpose in trying to use the db specific functionality like that?&amp;nbsp; A simple select should suffice - i.e. your not going to get any benefit from the syntax even if it did work.&lt;/P&gt;</description>
      <pubDate>Tue, 04 Dec 2018 14:51:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-SQL-Error-with-table-failure/m-p/518427#M140310</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2018-12-04T14:51:47Z</dc:date>
    </item>
    <item>
      <title>Re: Proc SQL Error: with table failure</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-SQL-Error-with-table-failure/m-p/518428#M140311</link>
      <description>&lt;P&gt;This example is a bit of a simple one. There are some more complex SQL solutions that I had at the previous job that abused creating a series of cascading "with statements" to use some of the functionality that SQL has that SAS doesn't, mainly multiple data partitioning followed by additional selects.&lt;/P&gt;</description>
      <pubDate>Tue, 04 Dec 2018 14:55:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-SQL-Error-with-table-failure/m-p/518428#M140311</guid>
      <dc:creator>ksnyder1986</dc:creator>
      <dc:date>2018-12-04T14:55:47Z</dc:date>
    </item>
    <item>
      <title>Re: Proc SQL Error: with table failure</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-SQL-Error-with-table-failure/m-p/518434#M140314</link>
      <description>&lt;P&gt;Well, to my mind, if you need to use database specific functionality like that, then code on the database.&amp;nbsp; Otherwise extract the data to SAS and process the data there.&amp;nbsp; You will find partitioning data is pretty easy in SAS - its a different way of thinking of the data.&amp;nbsp; So something that could be quite tricky in SQL can be done in one procedure in SAS.&amp;nbsp; No point programming another system from within SAS.&lt;/P&gt;
&lt;P&gt;One simple example, SQL does not have logical observation order, so lagging data would mean sub-querys or joins, but in SAS you can just lag to previous value.&amp;nbsp; Obs can be identifed just by _n_ as another example, which SQL can't do.&lt;/P&gt;</description>
      <pubDate>Tue, 04 Dec 2018 15:03:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-SQL-Error-with-table-failure/m-p/518434#M140314</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2018-12-04T15:03:08Z</dc:date>
    </item>
  </channel>
</rss>

