<?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: Reuse a table created using a Pass Through query in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Reuse-a-table-created-using-a-Pass-Through-query/m-p/444491#M28735</link>
    <description>&lt;P&gt;Please post your SAS log including your code, notes and errors. Helpful hint - if you are getting an error it is really useful if you tell us what it is and the code that generated it.&lt;/P&gt;</description>
    <pubDate>Sun, 11 Mar 2018 01:55:41 GMT</pubDate>
    <dc:creator>SASKiwi</dc:creator>
    <dc:date>2018-03-11T01:55:41Z</dc:date>
    <item>
      <title>Reuse a table created using a Pass Through query</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Reuse-a-table-created-using-a-Pass-Through-query/m-p/444365#M28722</link>
      <description>&lt;P&gt;Hi Forum,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a Pass Through query that creates a table &amp;amp; I want use the results of that table in&amp;nbsp;another query.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here's an example of my code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What I'm thinking is that I've created a table in a Schema I've named 'ora', so now I can use that as a prefix to get that table data back &amp;amp; use in the next query.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can anyone explain how I can reuse a tables results that have been created this way?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
connect to oracle as ora (path=(DESCRIPTION=(ADDRESS = (PROTOCOL = TCP)
(HOST = xxxxxxxxxxxxxxx.com)(PORT = 1234))
(CONNECT_DATA = (SERVICE_NAME=xxxxxxxx)))" 
user=xxxxxx pw=xxxxxxxx);
create table TABLE_3 as select * from connection to ora(
select distinct
A.ID
from TABLE_1 A
LEFT JOIN TABLE_2 B
ON A.ID = B.ID
)
Disconnect form ora
;QUIT;

proc sql;
connect to oracle as ora (path="(DESCRIPTION=(ADDRESS = (PROTOCOL = TCP)
(HOST = xxxxxxxxxxxxxxx.com)(PORT = 1234))
(CONNECT_DATA = (SERVICE_NAME=xxxxxxxx)))" 
user=xxxxxx pw=xxxxxxxx);
create table TABLE_4 as select * from connection to ora
(
select distinct
A.ID,
B.FIELD_1,
B.FIELD_2,
B.FIELD_3
&lt;STRONG&gt;from ora.TABLE_3 A&lt;/STRONG&gt;
LEFT JOIN TABLE_5 B
ON A.ID = B.ID
)
Disconnect form ora
;QUIT;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Now I want to use the results of the above query in another Pass Through.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 10 Mar 2018 09:13:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Reuse-a-table-created-using-a-Pass-Through-query/m-p/444365#M28722</guid>
      <dc:creator>OscarBoots2</dc:creator>
      <dc:date>2018-03-10T09:13:56Z</dc:date>
    </item>
    <item>
      <title>Re: Reuse a table created using a Pass Through query</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Reuse-a-table-created-using-a-Pass-Through-query/m-p/444367#M28723</link>
      <description>&lt;P&gt;You are creating a SAS table when you should be creating an Oracle one. This should help - I've added a second step.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
connect to oracle as ora (path=(DESCRIPTION=(ADDRESS = (PROTOCOL = TCP)
(HOST = xxxxxxxxxxxxxxx.com)(PORT = 1234))
(CONNECT_DATA = (SERVICE_NAME=xxxxxxxx)))" 
user=xxxxxx pw=xxxxxxxx);
execute (create table TABLE_3 as 
select distinct
A.ID
from TABLE_1 A
LEFT JOIN TABLE_2 B
ON A.ID = B.ID
) by ora;&lt;BR /&gt;&lt;BR /&gt;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;PRE class=" language-sas"&gt;&lt;CODE class="  language-sas"&gt;create &lt;SPAN class="token statement"&gt;table&lt;/SPAN&gt; TABLE_4 as &lt;SPAN class="token statement"&gt;select&lt;/SPAN&gt; &lt;SPAN class="token operator"&gt;*&lt;/SPAN&gt; &lt;SPAN class="token keyword"&gt;from&lt;/SPAN&gt; connection to ora
&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;
&lt;SPAN class="token statement"&gt;select&lt;/SPAN&gt; &lt;SPAN class="token keyword"&gt;distinct&lt;/SPAN&gt;
A&lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt;&lt;SPAN class="token keyword"&gt;ID&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;,&lt;/SPAN&gt;
B&lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt;FIELD_1&lt;SPAN class="token punctuation"&gt;,&lt;/SPAN&gt;
B&lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt;FIELD_2&lt;SPAN class="token punctuation"&gt;,&lt;/SPAN&gt;
B&lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt;FIELD_3
&lt;SPAN class="token keyword"&gt;from&lt;/SPAN&gt; TABLE_3 A
&lt;SPAN class="token function"&gt;LEFT&lt;/SPAN&gt; JOIN TABLE_5 B
ON A&lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt;&lt;SPAN class="token keyword"&gt;ID&lt;/SPAN&gt; &lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt; B&lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt;&lt;SPAN class="token keyword"&gt;ID&lt;/SPAN&gt;
&lt;SPAN class="token punctuation"&gt;);&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Disconnect from ora ;QUIT;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 10 Mar 2018 10:02:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Reuse-a-table-created-using-a-Pass-Through-query/m-p/444367#M28723</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2018-03-10T10:02:16Z</dc:date>
    </item>
    <item>
      <title>Re: Reuse a table created using a Pass Through query</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Reuse-a-table-created-using-a-Pass-Through-query/m-p/444368#M28724</link>
      <description>&lt;P&gt;Another way to describe the issue is to ask "If I create a table&amp;nbsp;with credentials as a "select * from connection to ora"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can I retrieve the table by a "select from ora.tablename" statement?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Or how would I go about it?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The table data I've created must go somewhere, so how do I access it?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 10 Mar 2018 09:57:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Reuse-a-table-created-using-a-Pass-Through-query/m-p/444368#M28724</guid>
      <dc:creator>OscarBoots2</dc:creator>
      <dc:date>2018-03-10T09:57:04Z</dc:date>
    </item>
    <item>
      <title>Re: Reuse a table created using a Pass Through query</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Reuse-a-table-created-using-a-Pass-Through-query/m-p/444369#M28725</link>
      <description>&lt;P&gt;Thanks SA SKiwi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How can I access that table in another Pass Through query?&lt;/P&gt;</description>
      <pubDate>Sat, 10 Mar 2018 09:59:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Reuse-a-table-created-using-a-Pass-Through-query/m-p/444369#M28725</guid>
      <dc:creator>OscarBoots2</dc:creator>
      <dc:date>2018-03-10T09:59:00Z</dc:date>
    </item>
    <item>
      <title>Re: Reuse a table created using a Pass Through query</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Reuse-a-table-created-using-a-Pass-Through-query/m-p/444373#M28726</link>
      <description>&lt;P&gt;See my modified query above.&lt;/P&gt;</description>
      <pubDate>Sat, 10 Mar 2018 10:42:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Reuse-a-table-created-using-a-Pass-Through-query/m-p/444373#M28726</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2018-03-10T10:42:07Z</dc:date>
    </item>
    <item>
      <title>Re: Reuse a table created using a Pass Through query</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Reuse-a-table-created-using-a-Pass-Through-query/m-p/444392#M28727</link>
      <description>&lt;P&gt;What you need is a way to tell SAS to use the same Oracle session for both connections.&lt;/P&gt;
&lt;P&gt;The way to do this is to use the connection=global option AND make another connection that persists between the two proc steps.&lt;/P&gt;
&lt;P&gt;Use a LIBNAME statement to do that.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;libname mylib oracle .... connection=global ;
proc sql noprint;
connect using mylib ;
execute 
(create .....
) by mylib;
quit;

proc sql ;
connect using mylib ;
select * from connection to mylib
(select ....)
;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 10 Mar 2018 14:41:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Reuse-a-table-created-using-a-Pass-Through-query/m-p/444392#M28727</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2018-03-10T14:41:57Z</dc:date>
    </item>
    <item>
      <title>Re: Reuse a table created using a Pass Through query</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Reuse-a-table-created-using-a-Pass-Through-query/m-p/444482#M28733</link>
      <description>&lt;P&gt;Thanks SASKiwi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm getting an 'Insufficient priveleges' error when running the first part which I think is due to the difference between my connection syntax &amp;amp; yours.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How can I adapt mine to suit the 'execute ... statement?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
connect to oracle as ora (path="(DESCRIPTION=(ADDRESS = (PROTOCOL = TCP)
(HOST = xxxxxxxxxxxxxxxxxx.com)(PORT = 1234)
(CONNECT_DATA = (SERVICE_NAME=xxxxxxx)))" 
user=xxxxxxx pw=xxxxxxx);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Sat, 10 Mar 2018 23:12:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Reuse-a-table-created-using-a-Pass-Through-query/m-p/444482#M28733</guid>
      <dc:creator>OscarBoots2</dc:creator>
      <dc:date>2018-03-10T23:12:56Z</dc:date>
    </item>
    <item>
      <title>Re: Reuse a table created using a Pass Through query</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Reuse-a-table-created-using-a-Pass-Through-query/m-p/444483#M28734</link>
      <description>&lt;P&gt;Thanks Tom,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm getting an error with the initial connection statement, can you adapt your first libname line to mine?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
connect to oracle as ora (path="(DESCRIPTION=(ADDRESS = (PROTOCOL = TCP)
(HOST = xxxxxxxxxxxxxxxxxx.com)(PORT = 1234)
(CONNECT_DATA = (SERVICE_NAME=xxxxxxx)))" 
user=xxxxxxx pw=xxxxxxx);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Sat, 10 Mar 2018 23:14:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Reuse-a-table-created-using-a-Pass-Through-query/m-p/444483#M28734</guid>
      <dc:creator>OscarBoots2</dc:creator>
      <dc:date>2018-03-10T23:14:46Z</dc:date>
    </item>
    <item>
      <title>Re: Reuse a table created using a Pass Through query</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Reuse-a-table-created-using-a-Pass-Through-query/m-p/444491#M28735</link>
      <description>&lt;P&gt;Please post your SAS log including your code, notes and errors. Helpful hint - if you are getting an error it is really useful if you tell us what it is and the code that generated it.&lt;/P&gt;</description>
      <pubDate>Sun, 11 Mar 2018 01:55:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Reuse-a-table-created-using-a-Pass-Through-query/m-p/444491#M28735</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2018-03-11T01:55:41Z</dc:date>
    </item>
    <item>
      <title>Re: Reuse a table created using a Pass Through query</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Reuse-a-table-created-using-a-Pass-Through-query/m-p/444494#M28736</link>
      <description>&lt;P&gt;I've had a look at some examples &amp;amp; this is what I've come up with, it still isn't right so I wonder if anyone can advise where I'm going wrong?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;libname mylib oracle path="(DESCRIPTION=(ADDRESS = (PROTOCOL = TCP)
(HOST = xxxxxxxxxxx.com)(PORT = 1234))
(CONNECT_DATA = (SERVICE_NAME=xxxxxxxx)))" ;
user=xxxxxxx pw=xxxxxxxx) connection=global;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 11 Mar 2018 02:00:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Reuse-a-table-created-using-a-Pass-Through-query/m-p/444494#M28736</guid>
      <dc:creator>OscarBoots2</dc:creator>
      <dc:date>2018-03-11T02:00:44Z</dc:date>
    </item>
    <item>
      <title>Re: Reuse a table created using a Pass Through query</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Reuse-a-table-created-using-a-Pass-Through-query/m-p/444495#M28737</link>
      <description>Hi SASKiwi, the error I'm getting is 'Invalid Username/Password' but I know this isn't the error. It only errors where I'm trying to set up yjis libname statement.</description>
      <pubDate>Sun, 11 Mar 2018 02:03:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Reuse-a-table-created-using-a-Pass-Through-query/m-p/444495#M28737</guid>
      <dc:creator>OscarBoots2</dc:creator>
      <dc:date>2018-03-11T02:03:31Z</dc:date>
    </item>
    <item>
      <title>Re: Reuse a table created using a Pass Through query</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Reuse-a-table-created-using-a-Pass-Through-query/m-p/444503#M28738</link>
      <description>&lt;P&gt;Here's the error msg from a basic select statement using your example;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;ERROR: ORACLE execute error: ORA-01031: insufficient privileges.&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 11 Mar 2018 02:33:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Reuse-a-table-created-using-a-Pass-Through-query/m-p/444503#M28738</guid>
      <dc:creator>OscarBoots2</dc:creator>
      <dc:date>2018-03-11T02:33:18Z</dc:date>
    </item>
    <item>
      <title>Re: Reuse a table created using a Pass Through query</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Reuse-a-table-created-using-a-Pass-Through-query/m-p/444508#M28739</link>
      <description>&lt;P&gt;Ok, here's where I'm at now;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The error is this - I can't see an error in the syntax or why this would error, any suggestions/ideas?&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;ERROR 22-322: Syntax error, expecting one of the following: ',', GROUP, HAVING, ORDER, WHERE.  &lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
25         connect to oracle as ora (path="(DESCRIPTION=(ADDRESS = (PROTOCOL = TCP)
26         (HOST = xxxxxxxxxxxxxxxxxx.com)(PORT = 1234)
27         (CONNECT_DATA = (SERVICE_NAME=xxxxxx)))"
28         user=xxxxxxx pw=XXXXXXXXXX);
29         
30         create table sales as select * from connection to ora
31                    (
32         select distinct
33         ID
34         
35         from Table_1
36         
37         WHERE rownum &amp;lt; 50
38         ) by ora;
                ___
                22
                76
ERROR 22-322: Syntax error, expecting one of the following: ',', GROUP, HAVING, ORDER, WHERE.  

ERROR 76-322: Syntax error, statement will be ignored.

NOTE: PROC SQL set option NOEXEC and will continue to check the syntax of statements.
39         
40         
41         create table TABLE_4 as select * from connection to ora
42         (
43         select DISTINCT
44         ID
45         from Table_1
46         );
2                                                          The SAS System                               09:40 Sunday, March 11, 2018

NOTE: Statement not executed due to NOEXEC option.
47         
48         Disconnect from ora ;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 11 Mar 2018 02:58:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Reuse-a-table-created-using-a-Pass-Through-query/m-p/444508#M28739</guid>
      <dc:creator>OscarBoots2</dc:creator>
      <dc:date>2018-03-11T02:58:18Z</dc:date>
    </item>
    <item>
      <title>Re: Reuse a table created using a Pass Through query</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Reuse-a-table-created-using-a-Pass-Through-query/m-p/444510#M28740</link>
      <description>&lt;P&gt;There are two ways to push code into the external database. Either via a query or just to run something. You have mixed the syntax of the two.&lt;/P&gt;
&lt;P&gt;For a query (something that returns a table of results) you name the database first.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;select .... from connection to DBNAME
(  .... SQL statement ... )
;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;To run something (something that does NOT return any results) you name the database last.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;execute
( .... SQL statement .... )
by DBNAME
;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 11 Mar 2018 03:08:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Reuse-a-table-created-using-a-Pass-Through-query/m-p/444510#M28740</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2018-03-11T03:08:34Z</dc:date>
    </item>
    <item>
      <title>Re: Reuse a table created using a Pass Through query</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Reuse-a-table-created-using-a-Pass-Through-query/m-p/444511#M28741</link>
      <description>&lt;P&gt;OK, to break this into its parts, I want to get this working first up,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;connect to oracle as ora (path="(DESCRIPTION=(ADDRESS = (PROTOCOL = TCP)
26         (HOST = xxxxxxxxxxxxxxxxxx.com)(PORT = 1234)
27         (CONNECT_DATA = (SERVICE_NAME=xxxxxx)))"
28         user=xxxxxxx pw=XXXXXXXXXX);
29         
30         create table sales as select * from connection to ora
31                    (
32         select distinct
33         ID
34         
35         from Table_1
36         
37         WHERE rownum &amp;lt; 50
38         ) by ora;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;So this should create a table that I can query later,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;As shown before, there's an error of some syntax missing, can you help me get this part working first?&lt;/P&gt;</description>
      <pubDate>Sun, 11 Mar 2018 03:17:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Reuse-a-table-created-using-a-Pass-Through-query/m-p/444511#M28741</guid>
      <dc:creator>OscarBoots2</dc:creator>
      <dc:date>2018-03-11T03:17:50Z</dc:date>
    </item>
    <item>
      <title>Re: Reuse a table created using a Pass Through query</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Reuse-a-table-created-using-a-Pass-Through-query/m-p/444523#M28744</link>
      <description>&lt;P&gt;Here's my latest &amp;amp; i'm getting an 'expecting a name error';&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql noprint;
connect to oracle as ora (path="(DESCRIPTION=(ADDRESS = (PROTOCOL = TCP)
(HOST = xxxxxxxxxxx.com)(PORT = 1234))
(CONNECT_DATA = (SERVICE_NAME=xxxxxxx)))" 
user=xxxxxxxx pw=xxxxxxxx);

execute(create table IDS as 

select DISTINCT 
ID

FROM table_1

WHERE ROWNUM &amp;lt; 50

by ora);

create table MORE_IDS as select * from connection to ora
(
select DISTINCT 
id

from IDS A
INNER JOIN TABLE_2 B
ON A.ID = B.ID

);
disconnect from ora;
quit;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;And here's the log script;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;                                                         The SAS System                               14:24 Sunday, March 11, 2018

1          ;*';*";*/;quit;run;
2          OPTIONS PAGENO=MIN;
3          %LET _CLIENTTASKLABEL='Program';
4          %LET _CLIENTPROCESSFLOWNAME='Process Flow';
5          %LET _SASPROGRAMFILE=;
8          
9          ODS _ALL_ CLOSE;
10         OPTIONS DEV=ACTIVEX;
11         GOPTIONS XPIXELS=0 YPIXELS=0;
12         FILENAME EGSR TEMP;
13         ODS tagsets.sasreport13(ID=EGSR) FILE=EGSR
14             STYLE=HtmlBlue
15             STYLESHEET=(URL="file:///C:/Program%20Files%20(x86)/SASHome/x86/SASEnterpriseGuide/7.1/Styles/HtmlBlue.css")
16             NOGTITLE
17             NOGFOOTNOTE
18             GPATH=&amp;amp;sasworklocation
19             ENCODING=UTF8
20             options(rolap="on")
21         ;
NOTE: Writing TAGSETS.SASREPORT13(EGSR) Body file: EGSR
22         
23         GOPTIONS ACCESSIBLE;
24         


25         proc sql noprint;
26         connect to oracle as ora (path="(DESCRIPTION=(ADDRESS = (PROTOCOL = TCP)
27         (HOST = xxxxxxxx.com)(PORT = 1234))
28         (CONNECT_DATA = (SERVICE_NAME=xxxxxxxx)))"
29         user=xxxxxxxxx pw=XXXXXXXXXX);
30         
31         execute(create table IDS as
32         
33         select DISTINCT
34         ID
35         
36         FROM table_1
37         
38         WHERE ROWNUM &amp;lt; 50
39         
40         by ora);
                  _
                  22
ERROR 22-322: Expecting a name.  &lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 11 Mar 2018 05:44:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Reuse-a-table-created-using-a-Pass-Through-query/m-p/444523#M28744</guid>
      <dc:creator>OscarBoots2</dc:creator>
      <dc:date>2018-03-11T05:44:46Z</dc:date>
    </item>
    <item>
      <title>Re: Reuse a table created using a Pass Through query</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Reuse-a-table-created-using-a-Pass-Through-query/m-p/444551#M28747</link>
      <description>&lt;P&gt;For SAS to understand what you are trying to do you need to &lt;STRONG&gt;follow the SYNTAX PATTERN&lt;/STRONG&gt; that the commands expect.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The pattern for an EXECUTE statement.is looking for&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;execute&amp;nbsp;&lt;/FONT&gt;&lt;FONT face="courier new,courier"&gt;(SQL STATEMENT&lt;/FONT&gt;&lt;FONT face="courier new,courier"&gt;)&amp;nbsp;&lt;FONT color="#FF0000"&gt;by DBNAME&amp;nbsp;&lt;/FONT&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Your command:&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;execute&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;(create table IDS as select DISTINCT&amp;nbsp;&amp;nbsp;ID&amp;nbsp;FROM table_1&amp;nbsp;WHERE ROWNUM &amp;lt; 50&amp;nbsp;&lt;FONT color="#FF0000"&gt;by ora&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;);&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Notice how your command has deviated from the pattern by putting the BY ORA inside the parentheses. This causes two errors. SAS is not seeing the expected BY XXXX after the remote sql command.&amp;nbsp; And if it did succeed in getting passed to the remote database then that wouldn't understand the BY ORA at the end.&amp;nbsp; It would be looking for proper SQL syntax there, so perhaps a "group by" or an "order by", but not just a bare "by".&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 11 Mar 2018 14:58:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Reuse-a-table-created-using-a-Pass-Through-query/m-p/444551#M28747</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2018-03-11T14:58:13Z</dc:date>
    </item>
    <item>
      <title>Re: Reuse a table created using a Pass Through query</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Reuse-a-table-created-using-a-Pass-Through-query/m-p/444614#M28749</link>
      <description>&lt;P&gt;Thanks Tom, that gives me the insufficient privileges error I was getting before.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I think I'll use the other syntax other than the execute version.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 12 Mar 2018 01:20:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Reuse-a-table-created-using-a-Pass-Through-query/m-p/444614#M28749</guid>
      <dc:creator>OscarBoots2</dc:creator>
      <dc:date>2018-03-12T01:20:30Z</dc:date>
    </item>
    <item>
      <title>Re: Reuse a table created using a Pass Through query</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Reuse-a-table-created-using-a-Pass-Through-query/m-p/444618#M28750</link>
      <description>&lt;P&gt;OK, using this script I get the 'Table does not exist error.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How do I connect to the table I just created in ora?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
connect to oracle as ora (path="(DESCRIPTION=(ADDRESS = (PROTOCOL = TCP)
(HOST = xxxxxxxxx.com)(PORT = 1234))
(CONNECT_DATA = (SERVICE_NAME=xxxxxxxx)))" 
user=xxxxxxxx pw=xxxxxx);
         
create table IDS as select * from connection to ora
(
select DISTINCT 
ID

FROM table_1

WHERE ROWNUM &amp;lt; 50

)
;QUIT;

PROC SQL;
connect to oracle as ora (path="(DESCRIPTION=(ADDRESS = (PROTOCOL = TCP)
(HOST = xxxxxxxxxx.com)(PORT = 1234))
(CONNECT_DATA = (SERVICE_NAME=xxxxxxx)))" 
user=xxxxxxxx pw=xxxxxxxxx);
 
create table TABLE_2 as select * from connection to ora
(
select DISTINCT 
A.ID;
B.SALES

from ora.table1 A    ------- HOW DO I ACCESS THIS TABLE?
INNER JOIN dbc.table_3 B
ON A.ID = B.ID
);
         
Disconnect from ora ;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 12 Mar 2018 01:53:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Reuse-a-table-created-using-a-Pass-Through-query/m-p/444618#M28750</guid>
      <dc:creator>OscarBoots2</dc:creator>
      <dc:date>2018-03-12T01:53:25Z</dc:date>
    </item>
    <item>
      <title>Re: Reuse a table created using a Pass Through query</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Reuse-a-table-created-using-a-Pass-Through-query/m-p/444619#M28751</link>
      <description>Sorry made an error in the ref to the first query, ora.table1 should be ora.IDS</description>
      <pubDate>Mon, 12 Mar 2018 02:11:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Reuse-a-table-created-using-a-Pass-Through-query/m-p/444619#M28751</guid>
      <dc:creator>OscarBoots2</dc:creator>
      <dc:date>2018-03-12T02:11:16Z</dc:date>
    </item>
  </channel>
</rss>

