<?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 a temp table in Postgres DB in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Create-a-temp-table-in-Postgres-DB/m-p/790042#M252919</link>
    <description>Perhaps create the table in SAS and then export when you are done.</description>
    <pubDate>Thu, 13 Jan 2022 17:30:25 GMT</pubDate>
    <dc:creator>HB</dc:creator>
    <dc:date>2022-01-13T17:30:25Z</dc:date>
    <item>
      <title>Create a temp table in Postgres DB</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-a-temp-table-in-Postgres-DB/m-p/790014#M252904</link>
      <description>&lt;P&gt;I'm struggling with the syntax of creating a temp table in Postgres, as I do not have rights to create a permanent table. Here's what I tried:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;libname mypg odbc DATAsrc=&amp;lt;data-source&amp;gt;
authdomain="&amp;lt;authdomain&amp;gt;"
schema=&amp;lt;schema&amp;gt;;&amp;nbsp;

&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Libname works fine, and I'm able to query tables.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Temp table creation is where I get stuck:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;proc sql;
create table mypg.'#pathway_set_tmp'n (pathwayid int);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Error received:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;EM&gt;ERROR: Error attempting to CREATE a DBMS table. ERROR: CLI execute error: ERROR: syntax error at or near "#"; Error while executing &lt;/EM&gt;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&lt;EM&gt;the query.&lt;/EM&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advance!&lt;/P&gt;</description>
      <pubDate>Thu, 13 Jan 2022 16:21:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-a-temp-table-in-Postgres-DB/m-p/790014#M252904</guid>
      <dc:creator>PeteSAS</dc:creator>
      <dc:date>2022-01-13T16:21:26Z</dc:date>
    </item>
    <item>
      <title>Re: Create a temp table in Postgres DB</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-a-temp-table-in-Postgres-DB/m-p/790041#M252918</link>
      <description>&lt;P&gt;Have you tried the SQL Pass-through facility ?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql noerrorstop;
 connect to postgres as x1(server=mysrv1 port=5432 
    user=mysur1 password='mypwd1' database=mydb1);

 select * from connection to x1 (&amp;lt;Your P-SQL Query Here&amp;gt;);

 disconnect from x1;
 quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 13 Jan 2022 17:30:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-a-temp-table-in-Postgres-DB/m-p/790041#M252918</guid>
      <dc:creator>r_behata</dc:creator>
      <dc:date>2022-01-13T17:30:15Z</dc:date>
    </item>
    <item>
      <title>Re: Create a temp table in Postgres DB</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-a-temp-table-in-Postgres-DB/m-p/790042#M252919</link>
      <description>Perhaps create the table in SAS and then export when you are done.</description>
      <pubDate>Thu, 13 Jan 2022 17:30:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-a-temp-table-in-Postgres-DB/m-p/790042#M252919</guid>
      <dc:creator>HB</dc:creator>
      <dc:date>2022-01-13T17:30:25Z</dc:date>
    </item>
    <item>
      <title>Re: Create a temp table in Postgres DB</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-a-temp-table-in-Postgres-DB/m-p/790044#M252920</link>
      <description>&lt;P&gt;Thanks for the reply, I played around with that a little along the way - is there a way to specify the schema, and use windows authentication so I don't have to hard-code my user/pwd?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 13 Jan 2022 17:35:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-a-temp-table-in-Postgres-DB/m-p/790044#M252920</guid>
      <dc:creator>PeteSAS</dc:creator>
      <dc:date>2022-01-13T17:35:16Z</dc:date>
    </item>
    <item>
      <title>Re: Create a temp table in Postgres DB</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-a-temp-table-in-Postgres-DB/m-p/790048#M252921</link>
      <description>&lt;P&gt;Thanks, could you be a little more specific in regard to exporting the table to Postgres as a temp table? Example would be much appreciated.&lt;/P&gt;</description>
      <pubDate>Thu, 13 Jan 2022 17:43:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-a-temp-table-in-Postgres-DB/m-p/790048#M252921</guid>
      <dc:creator>PeteSAS</dc:creator>
      <dc:date>2022-01-13T17:43:17Z</dc:date>
    </item>
    <item>
      <title>Re: Create a temp table in Postgres DB</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-a-temp-table-in-Postgres-DB/m-p/790077#M252927</link>
      <description>&lt;P&gt;This link shows you how to create Postgres temporary tables:&amp;nbsp;&lt;A href="https://www.postgresqltutorial.com/postgresql-temporary-table/" target="_blank"&gt;https://www.postgresqltutorial.com/postgresql-temporary-table/&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you use SQL Passthru and the Postgres examples in the link it should work. Something like this?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;libname mypg odbc DATAsrc=&amp;lt;data-source&amp;gt;
authdomain="&amp;lt;authdomain&amp;gt;"
schema=&amp;lt;schema&amp;gt;; 

proc sql noprint;
  connect using mypg;
execute (CREATE TEMPORARY TABLE temp_table_name(MyTempTable);) by mypg;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 13 Jan 2022 21:37:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-a-temp-table-in-Postgres-DB/m-p/790077#M252927</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2022-01-13T21:37:53Z</dc:date>
    </item>
  </channel>
</rss>

