<?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: Using SAS to send information to an Oracle Table in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Using-SAS-to-send-information-to-an-Oracle-Table/m-p/914359#M44259</link>
    <description>&lt;P&gt;One last Question.&lt;/P&gt;
&lt;P&gt;As I have mentioned previously, I have little experience with data transfert from SAS dataset to an Oracle DB.&lt;/P&gt;
&lt;P&gt;This script below works very well&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc append base=oracle.temp data=SurveyResponse;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But when I run this script twice, we see duplicate records into the Oracle table.&lt;/P&gt;
&lt;P&gt;How do we update an existing Oracle table.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Because When we execute this append command the first time it create the oracle table and transfer the content of the SAS dataset into it.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So which command do we use to transfer only the new information (delta load) into the Oracle table.&lt;/P&gt;
&lt;P&gt;Thanks for you help which is very appreciated.&lt;/P&gt;</description>
    <pubDate>Fri, 02 Feb 2024 22:45:27 GMT</pubDate>
    <dc:creator>alepage</dc:creator>
    <dc:date>2024-02-02T22:45:27Z</dc:date>
    <item>
      <title>Using SAS to send information to an Oracle Table</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Using-SAS-to-send-information-to-an-Oracle-Table/m-p/914070#M44243</link>
      <description>&lt;P&gt;Hello,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;usually, I connecting to an existing Oracle table to import the Data into a SAS Dataset.&lt;/P&gt;
&lt;P&gt;Now, I need to create an Oracle table (specific Database, specific Schema) then send into it, the content of a SAS dataset into it.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;However, I could create the Oracle table with it's structure using Toad, then using SAS to send the data into it.&lt;/P&gt;
&lt;P&gt;Or I can use SAS to create the Oracle Table with it's stucture then send the data into it.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;As I never did this task, Could it be possible to know which one is the best approach and could it be possible to provide code example.&amp;nbsp; You can use the sashelp.class as data source for example.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Regards,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 01 Feb 2024 19:26:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Using-SAS-to-send-information-to-an-Oracle-Table/m-p/914070#M44243</guid>
      <dc:creator>alepage</dc:creator>
      <dc:date>2024-02-01T19:26:14Z</dc:date>
    </item>
    <item>
      <title>Re: Using SAS to send information to an Oracle Table</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Using-SAS-to-send-information-to-an-Oracle-Table/m-p/914155#M44250</link>
      <description>&lt;P&gt;Should not matter.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can let SAS define the table/variables.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;libname myora oracle .... ;
proc append base=myora.dbtable data=sastable;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Or do it your self&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;libname myora oracle .... ;
proc sql;
  connect using myora;
  execute by myora
( create table ...... oracle code here .... )
  ;
quit;

proc append base=myora.dbtable data=sastable;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 02 Feb 2024 04:30:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Using-SAS-to-send-information-to-an-Oracle-Table/m-p/914155#M44250</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2024-02-02T04:30:44Z</dc:date>
    </item>
    <item>
      <title>Re: Using SAS to send information to an Oracle Table</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Using-SAS-to-send-information-to-an-Oracle-Table/m-p/914156#M44251</link>
      <description>&lt;P&gt;Using Proc Append like in&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt;'s first sample will not only load the DB table but also create it if it doesn't exist already.&lt;/P&gt;
&lt;P&gt;I normally prefer to create database tables explicitly using database specific syntax (explicit pass-through SQL) - which is what&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt;'s 2nd sample code does.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you're using implicit SQL (=let SAS translate it to the DB SQL syntax) then using the following options will show in the SAS log what SQL SAS actually sends to the DB.&lt;/P&gt;
&lt;PRE&gt;options sastrace=',,;d' sastraceloc=saslog nostsuffix;&lt;/PRE&gt;
&lt;P&gt;Should you ever have issues with code that SAS sends to the DB (syntax or performance) then read in the docu how to "configure" option sastrace="...." to get more debug info into your SAS log.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 02 Feb 2024 04:45:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Using-SAS-to-send-information-to-an-Oracle-Table/m-p/914156#M44251</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2024-02-02T04:45:55Z</dc:date>
    </item>
    <item>
      <title>Re: Using SAS to send information to an Oracle Table</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Using-SAS-to-send-information-to-an-Oracle-Table/m-p/914193#M44252</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This append proc works very well&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;libname myora oracle .... ;
proc append base=myora.dbtable data=sastable;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;But into my SAS dataset, the startdate, enddate, locationlatitude, locationlongitude, are in varchar2 format while the two first should be date, and the two last num(10,6).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Where do we make the conversion into the SAS dataset or in the Oracle Table&lt;/P&gt;
&lt;P&gt;and how&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please provide a sas snippet&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;
&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;
&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>Fri, 02 Feb 2024 12:58:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Using-SAS-to-send-information-to-an-Oracle-Table/m-p/914193#M44252</guid>
      <dc:creator>alepage</dc:creator>
      <dc:date>2024-02-02T12:58:01Z</dc:date>
    </item>
    <item>
      <title>Re: Using SAS to send information to an Oracle Table</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Using-SAS-to-send-information-to-an-Oracle-Table/m-p/914202#M44253</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/76331"&gt;@alepage&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This append proc works very well&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;libname myora oracle .... ;
proc append base=myora.dbtable data=sastable;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;But into my SAS dataset, the startdate, enddate, locationlatitude, locationlongitude, are in varchar2 format while the two first should be date, and the two last num(10,6).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Where do we make the conversion into the SAS dataset or in the Oracle Table&lt;/P&gt;
&lt;P&gt;and how&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please provide a sas snippet&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;That does not seem likely if the variables where numeric in SAS they should be numeric in Oracle.&amp;nbsp; They might be floating point instead of fixed decimal place numbers just because SAS only has floating point numbers.&amp;nbsp; And if the date variables really are numeric with date values (number of days) and have a date type display format attached (like DATE9.) then SAS should have created a date variable in Oracle.&amp;nbsp; Although last time I used Oracle it only supported DATETYPE variables (number of seconds) and not DATE variables (number of days).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Try using the DBTYPE= dataset option to tell SAS what type of Oracle variable should be created for the variable coming from SAS.&amp;nbsp; When going the other way (reading from Oracle) you can use the DBSASTYPE= dataset option to tell SAS what type of SAS variable to create from the Oracle variable.&lt;/P&gt;</description>
      <pubDate>Fri, 02 Feb 2024 13:37:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Using-SAS-to-send-information-to-an-Oracle-Table/m-p/914202#M44253</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2024-02-02T13:37:27Z</dc:date>
    </item>
    <item>
      <title>Re: Using SAS to send information to an Oracle Table</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Using-SAS-to-send-information-to-an-Oracle-Table/m-p/914359#M44259</link>
      <description>&lt;P&gt;One last Question.&lt;/P&gt;
&lt;P&gt;As I have mentioned previously, I have little experience with data transfert from SAS dataset to an Oracle DB.&lt;/P&gt;
&lt;P&gt;This script below works very well&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc append base=oracle.temp data=SurveyResponse;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But when I run this script twice, we see duplicate records into the Oracle table.&lt;/P&gt;
&lt;P&gt;How do we update an existing Oracle table.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Because When we execute this append command the first time it create the oracle table and transfer the content of the SAS dataset into it.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So which command do we use to transfer only the new information (delta load) into the Oracle table.&lt;/P&gt;
&lt;P&gt;Thanks for you help which is very appreciated.&lt;/P&gt;</description>
      <pubDate>Fri, 02 Feb 2024 22:45:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Using-SAS-to-send-information-to-an-Oracle-Table/m-p/914359#M44259</guid>
      <dc:creator>alepage</dc:creator>
      <dc:date>2024-02-02T22:45:27Z</dc:date>
    </item>
    <item>
      <title>Re: Using SAS to send information to an Oracle Table</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Using-SAS-to-send-information-to-an-Oracle-Table/m-p/914370#M44261</link>
      <description>&lt;P&gt;As the name indicates Proc Append appends (inserts) data to a table. If you run it twice you've got duplicates.&lt;/P&gt;
&lt;P&gt;One of the reasons I prefer to create tables in databases explicitly via code is to also add Primary Key constraints and potentially indexes. If you've got a primary key constraint defined on the table then Oracle will reject the records (and return an error) in case you're trying to insert a record twice.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;As for updating a table:&lt;/P&gt;
&lt;P&gt;Using Proc SQL how would you do this if your target would be a SAS table? It's pretty much the same with a target table in a database.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;One of the additional things you need to consider when interfacing with a database is data movement.&lt;/P&gt;
&lt;P&gt;For example for a SQL update you need to write SQL that compares your source data with your target data and only updates rows in target where there is a change. If your source and target table are not in the same location (like both in Oracle) then such a comparison could cause a lot of data movement over the network with a huge impact on performance.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The way such loads are normally done:&amp;nbsp;&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;Load your source SAS table into an empty DB staging table (potentially a temporary table).
&lt;OL&gt;
&lt;LI&gt;&lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/acreldb/n0irpkyp22l7vzn1il9lx6f4wmx9.htm" target="_blank" rel="noopener"&gt;https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/acreldb/n0irpkyp22l7vzn1il9lx6f4wmx9.htm&lt;/A&gt;&amp;nbsp;&lt;/LI&gt;
&lt;/OL&gt;
&lt;/LI&gt;
&lt;LI&gt;Write explicit pass-through SQL (=SQL in the DB flavor that SAS just send to the DB for execution) that does the update or insert.
&lt;OL&gt;
&lt;LI&gt;With databases like Oracle there is also a MERGE statement that allows you to combine Insert and Update in a single SQL.&lt;BR /&gt;&lt;A href="https://docs.oracle.com/en/database/oracle/oracle-database/19/sqlrf/MERGE.html#GUID-5692CCB7-24D9-4C0E-81A7-A22436DC968F" target="_blank" rel="noopener"&gt;https://docs.oracle.com/en/database/oracle/oracle-database/19/sqlrf/MERGE.html#GUID-5692CCB7-24D9-4C0E-81A7-A22436DC968F&lt;/A&gt;&amp;nbsp;&lt;/LI&gt;
&lt;/OL&gt;
&lt;/LI&gt;
&lt;/OL&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 03 Feb 2024 02:57:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Using-SAS-to-send-information-to-an-Oracle-Table/m-p/914370#M44261</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2024-02-03T02:57:33Z</dc:date>
    </item>
  </channel>
</rss>

