<?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: Insert into a table in Oracle Using Proc SQL; in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Insert-into-a-table-in-Oracle-Using-Proc-SQL/m-p/438266#M69072</link>
    <description>&lt;P&gt;Yes I have Issue in the query..&lt;/P&gt;&lt;P&gt;After INSERT INTO it throws me this error&lt;/P&gt;&lt;P&gt;ERROR 79-322: Expecting a (&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;after order by it throws me&amp;nbsp;&lt;/P&gt;&lt;P&gt;ERROR 180-322: Statement is not valid or it is used out of proper order.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I understand somewhere I am doing wrong in semicolon and (, help to write this query properly in SAS proc SQL;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1. I wanna Insert the Select statement value in Entity_date table&lt;/P&gt;&lt;P&gt;2. And store that as SAS dataset in external location as well.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in Advance!!!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sun, 18 Feb 2018 16:27:00 GMT</pubDate>
    <dc:creator>Pradeepbanu</dc:creator>
    <dc:date>2018-02-18T16:27:00Z</dc:date>
    <item>
      <title>Insert into a table in Oracle Using Proc SQL;</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Insert-into-a-table-in-Oracle-Using-Proc-SQL/m-p/438264#M69070</link>
      <description>&lt;P&gt;&lt;BR /&gt;%let usr="usernm";&lt;BR /&gt;%let psswd="12345";&lt;BR /&gt;%let path=PATHORAC;&lt;/P&gt;&lt;P&gt;%put path: &amp;amp;path;&lt;/P&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;connect to oracle (user=&amp;amp;usr&lt;BR /&gt;password=&amp;amp;psswd&lt;BR /&gt;path=&amp;amp;path&lt;BR /&gt;buffsize=5000);&lt;/P&gt;&lt;P&gt;create table work.SAS_Entity_date as&lt;BR /&gt;select *&lt;BR /&gt;from connection to oracle&lt;BR /&gt;&lt;BR /&gt;INSERT INTO ENTITY_DATES_WK13&lt;BR /&gt;SELECT DISTINCT 0,NULL WEEK_NAME,TO_CHAR(WEEK_BEGIN,'YYYYMMDD') WEEK_BEGIN,TO_CHAR(WEEK_END,'YYYYMMDD') WEEK_END,NULL WEEK_ABBREVIATION,WEEK_ABBREVIATION,WEEK_NAME,&lt;BR /&gt;WEEK_LABEL&lt;BR /&gt;FROM CW_CALENDAR_DATE&lt;BR /&gt;WHERE CALENDAR_DATE_KEY BETWEEN&lt;BR /&gt;(&lt;/P&gt;&lt;P&gt;SELECT TO_CHAR( TO_DATE(AS_OF_DATE,'YYYYMMDD')-98,'YYYYMMDD' ) AS WEEK_13&lt;BR /&gt;FROM&lt;BR /&gt;(&lt;BR /&gt;SELECT MAX(REPORTING_DATE_KEY) AS_OF_DATE FROM FACT_TABLE&lt;BR /&gt;)&lt;BR /&gt;) AND&lt;/P&gt;&lt;P&gt;(&lt;BR /&gt;SELECT MAX(REPORTING_DATE_KEY) AS_OF_DATE FROM FACT_TABLE&lt;BR /&gt;)&lt;BR /&gt;ORDER BY WEEK_BEGIN DESC;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;(select *&lt;BR /&gt;from flm7677.ENTITY_DATES_WK13);&lt;BR /&gt;quit;&lt;/P&gt;&lt;P&gt;proc print data = work.SAS_Entity_date;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Do subqueries like this are supported in this proc? If not what would be the better way? I am fairly new to SAS, sorry if this is a simple question.&lt;/P&gt;</description>
      <pubDate>Sun, 18 Feb 2018 16:11:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Insert-into-a-table-in-Oracle-Using-Proc-SQL/m-p/438264#M69070</guid>
      <dc:creator>Pradeepbanu</dc:creator>
      <dc:date>2018-02-18T16:11:40Z</dc:date>
    </item>
    <item>
      <title>Re: Insert into a table in Oracle Using Proc SQL;</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Insert-into-a-table-in-Oracle-Using-Proc-SQL/m-p/438265#M69071</link>
      <description>&lt;P&gt;the whole query is in oracle.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;when you use connect statement query is directly sent to Oracle.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;subquery are allowed in oracle, SAS and almost all versions where SQL is implemented.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Are&amp;nbsp; you have any issues with query&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 18 Feb 2018 16:21:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Insert-into-a-table-in-Oracle-Using-Proc-SQL/m-p/438265#M69071</guid>
      <dc:creator>kiranv_</dc:creator>
      <dc:date>2018-02-18T16:21:27Z</dc:date>
    </item>
    <item>
      <title>Re: Insert into a table in Oracle Using Proc SQL;</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Insert-into-a-table-in-Oracle-Using-Proc-SQL/m-p/438266#M69072</link>
      <description>&lt;P&gt;Yes I have Issue in the query..&lt;/P&gt;&lt;P&gt;After INSERT INTO it throws me this error&lt;/P&gt;&lt;P&gt;ERROR 79-322: Expecting a (&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;after order by it throws me&amp;nbsp;&lt;/P&gt;&lt;P&gt;ERROR 180-322: Statement is not valid or it is used out of proper order.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I understand somewhere I am doing wrong in semicolon and (, help to write this query properly in SAS proc SQL;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1. I wanna Insert the Select statement value in Entity_date table&lt;/P&gt;&lt;P&gt;2. And store that as SAS dataset in external location as well.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in Advance!!!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 18 Feb 2018 16:27:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Insert-into-a-table-in-Oracle-Using-Proc-SQL/m-p/438266#M69072</guid>
      <dc:creator>Pradeepbanu</dc:creator>
      <dc:date>2018-02-18T16:27:00Z</dc:date>
    </item>
    <item>
      <title>Re: Insert into a table in Oracle Using Proc SQL;</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Insert-into-a-table-in-Oracle-Using-Proc-SQL/m-p/438269#M69073</link>
      <description>&lt;P&gt;try this and let me know&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;

connect to oracle (user=&amp;amp;usr
password=&amp;amp;psswd
path=&amp;amp;path
buffsize=5000);

create table work.SAS_Entity_date as
select *
from connection to oracle

(
SELECT DISTINCT 0,NULL WEEK_NAME,TO_CHAR(WEEK_BEGIN,'YYYYMMDD') WEEK_BEGIN,TO_CHAR(WEEK_END,'YYYYMMDD') WEEK_END,NULL WEEK_ABBREVIATION,WEEK_ABBREVIATION,WEEK_NAME,
WEEK_LABEL
FROM CW_CALENDAR_DATE
WHERE CALENDAR_DATE_KEY BETWEEN
(

SELECT TO_CHAR( TO_DATE(AS_OF_DATE,'YYYYMMDD')-98,'YYYYMMDD' ) AS WEEK_13
FROM
(
SELECT MAX(REPORTING_DATE_KEY) AS_OF_DATE FROM FACT_TABLE
)
) AND

(
SELECT MAX(REPORTING_DATE_KEY) AS_OF_DATE FROM FACT_TABLE
))
  disconnect from oracle; 
    quit; ;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 18 Feb 2018 16:43:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Insert-into-a-table-in-Oracle-Using-Proc-SQL/m-p/438269#M69073</guid>
      <dc:creator>kiranv_</dc:creator>
      <dc:date>2018-02-18T16:43:42Z</dc:date>
    </item>
    <item>
      <title>Re: Insert into a table in Oracle Using Proc SQL;</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Insert-into-a-table-in-Oracle-Using-Proc-SQL/m-p/438275#M69074</link>
      <description>&lt;P&gt;Fantastic!!! It works..,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When I try adding INSERT INTO ENTITY_DATES_WK13 (this table is in Oracle DB) on the top of Select it throws me the error&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;ERROR: ORACLE prepare error: ORA-24333: zero iteration count.&lt;/P&gt;&lt;P&gt;SQL statement: insert INTO flm7677.ENTITY_DATES_WK13 Select ....&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 18 Feb 2018 17:17:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Insert-into-a-table-in-Oracle-Using-Proc-SQL/m-p/438275#M69074</guid>
      <dc:creator>Pradeepbanu</dc:creator>
      <dc:date>2018-02-18T17:17:02Z</dc:date>
    </item>
    <item>
      <title>Re: Insert into a table in Oracle Using Proc SQL;</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Insert-into-a-table-in-Oracle-Using-Proc-SQL/m-p/438278#M69075</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;

connect to oracle (user=&amp;amp;usr
password=&amp;amp;psswd
path=&amp;amp;path
buffsize=5000);



execute(
insert into oracletable
SELECT DISTINCT 0,NULL WEEK_NAME,TO_CHAR(WEEK_BEGIN,'YYYYMMDD') WEEK_BEGIN,TO_CHAR(WEEK_END,'YYYYMMDD') WEEK_END,NULL WEEK_ABBREVIATION,WEEK_ABBREVIATION,WEEK_NAME,
WEEK_LABEL
FROM CW_CALENDAR_DATE
WHERE CALENDAR_DATE_KEY BETWEEN
(

SELECT TO_CHAR( TO_DATE(AS_OF_DATE,'YYYYMMDD')-98,'YYYYMMDD' ) AS WEEK_13
FROM
(
SELECT MAX(REPORTING_DATE_KEY) AS_OF_DATE FROM FACT_TABLE
)
) AND

(
SELECT MAX(REPORTING_DATE_KEY) AS_OF_DATE FROM FACT_TABLE
)) by oracle;
  disconnect from oracle; 
    quit; ;

proc sql;    
  connect to oracle (user=&amp;amp;usr
password=&amp;amp;psswd
path=&amp;amp;path
buffsize=5000); 

   create table sastab.newtable as
  select * 
     from connection to oracle      
        (select *          
           from oracletable);  

      disconnect from oracle; 
    quit;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;create sas table needs oracle select. that is why the error.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;select * from (insert into does not work)&lt;/P&gt;
&lt;P&gt;select * from (select * from table). to do your kind of query you need to do it a different way&lt;/P&gt;
&lt;P&gt;first do insert into oracle table and then do select&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 18 Feb 2018 20:46:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Insert-into-a-table-in-Oracle-Using-Proc-SQL/m-p/438278#M69075</guid>
      <dc:creator>kiranv_</dc:creator>
      <dc:date>2018-02-18T20:46:34Z</dc:date>
    </item>
    <item>
      <title>Re: Insert into a table in Oracle Using Proc SQL;</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Insert-into-a-table-in-Oracle-Using-Proc-SQL/m-p/438280#M69076</link>
      <description>Thank you so much!! Really appreciate your effort!! &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;</description>
      <pubDate>Sun, 18 Feb 2018 17:39:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Insert-into-a-table-in-Oracle-Using-Proc-SQL/m-p/438280#M69076</guid>
      <dc:creator>Pradeepbanu</dc:creator>
      <dc:date>2018-02-18T17:39:39Z</dc:date>
    </item>
    <item>
      <title>Re: Insert into a table in Oracle Using Proc SQL;</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Insert-into-a-table-in-Oracle-Using-Proc-SQL/m-p/438292#M69078</link>
      <description>&lt;P&gt;There are two ways to push code into the remote database.&amp;nbsp; You can use&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;SELECT ... FROM CONNECTION TO x ();&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Or you can use&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;EXECUTE () BYx;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Use the first form when the statement returns results. Use the second form for statements like INSERT that do not return results.&lt;/P&gt;</description>
      <pubDate>Sun, 18 Feb 2018 19:36:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Insert-into-a-table-in-Oracle-Using-Proc-SQL/m-p/438292#M69078</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2018-02-18T19:36:09Z</dc:date>
    </item>
  </channel>
</rss>

