<?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 datastep.runcode loading from oracle in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/datastep-runcode-loading-from-oracle/m-p/799609#M314448</link>
    <description>&lt;P&gt;works:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;LIBNAME myora ORACLE PATH=BIxxx.vwxxxx.de USER=SAS PASSWORD='xcxxxsds';

data MKT.CONSENTIMIENTOS(promote=yes);
set myora.CONSENTIMIENTOS;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;FONT color="#FF0000"&gt;does not work:&lt;/FONT&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc cas;
function doesTableExist(casLib,casTable);
  table.tableExists result=r status=rc / caslib=casLib table=casTable;
  tableExists = dictionary(r, "exists");
  return tableExists;
end func;
tableExists = doesTableExist("mkt", "MKT.CONSENTIMIENTOS");
if tableExists=0 then 
dataStep.runCode result=r status=rc / code='/* BEGIN data step with the output table data */
data CONSENTIMIENTOS(caslib="mkt" promote=yes);
set CONSENTIMIENTOS(caslib="myora");
run;';
run;

proc cas;
dataStep.runCode result=r status=rc / code='/* BEGIN data step with the output table data */
data CONSENTIMIENTOS(caslib="mkt" promote=yes);
set MYORA.CONSENTIMIENTOS;
run;';
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;error code&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="pic.png" style="width: 860px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/69072iBE8D9D9626DD1774/image-size/large?v=v2&amp;amp;px=999" role="button" title="pic.png" alt="pic.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
    <pubDate>Wed, 02 Mar 2022 16:38:57 GMT</pubDate>
    <dc:creator>acordes</dc:creator>
    <dc:date>2022-03-02T16:38:57Z</dc:date>
    <item>
      <title>datastep.runcode loading from oracle</title>
      <link>https://communities.sas.com/t5/SAS-Programming/datastep-runcode-loading-from-oracle/m-p/799609#M314448</link>
      <description>&lt;P&gt;works:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;LIBNAME myora ORACLE PATH=BIxxx.vwxxxx.de USER=SAS PASSWORD='xcxxxsds';

data MKT.CONSENTIMIENTOS(promote=yes);
set myora.CONSENTIMIENTOS;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;FONT color="#FF0000"&gt;does not work:&lt;/FONT&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc cas;
function doesTableExist(casLib,casTable);
  table.tableExists result=r status=rc / caslib=casLib table=casTable;
  tableExists = dictionary(r, "exists");
  return tableExists;
end func;
tableExists = doesTableExist("mkt", "MKT.CONSENTIMIENTOS");
if tableExists=0 then 
dataStep.runCode result=r status=rc / code='/* BEGIN data step with the output table data */
data CONSENTIMIENTOS(caslib="mkt" promote=yes);
set CONSENTIMIENTOS(caslib="myora");
run;';
run;

proc cas;
dataStep.runCode result=r status=rc / code='/* BEGIN data step with the output table data */
data CONSENTIMIENTOS(caslib="mkt" promote=yes);
set MYORA.CONSENTIMIENTOS;
run;';
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;error code&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="pic.png" style="width: 860px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/69072iBE8D9D9626DD1774/image-size/large?v=v2&amp;amp;px=999" role="button" title="pic.png" alt="pic.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 02 Mar 2022 16:38:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/datastep-runcode-loading-from-oracle/m-p/799609#M314448</guid>
      <dc:creator>acordes</dc:creator>
      <dc:date>2022-03-02T16:38:57Z</dc:date>
    </item>
    <item>
      <title>Re: datastep.runcode loading from oracle</title>
      <link>https://communities.sas.com/t5/SAS-Programming/datastep-runcode-loading-from-oracle/m-p/799851#M314559</link>
      <description>&lt;P&gt;Code running in CAS has absolutely no access to SAS libraries on the Compute Server. This means that your DATA step in CAS can't use data from the myOra libref in the SAS session. To use Oracle in CAS, you need an Oracle-based CASLIB. Here is some example code:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;cas mySession;
/* Establish an Oracle caslib so you can access Oracle in CAS*/
caslib myOra desc="Oracle caslib" 
              datasource=(
                srctype="oracle"
               ,username="SAS"
               ,pwd='xcxxxsds'
               ,path="BIxxx.vwxxxx.de"
                ) 
      ;

proc cas;

function doesTableExist(casLib,casTable);
  table.tableExists result=r status=rc / caslib=casLib table=casTable;
  tableExists = dictionary(r, "exists");
  return tableExists;
end func;

/* 
 It's easier to write DATA steps in a source block than to write 
 the code within a string parameter. Use caslib.table_name format
 to reference CAS tables when running in CAS. 
*/
source myDataStep;
data mkt.CONSENTIMIENTOS(promote=yes);
   set myOra.CONSENTIMIENTOS;
run;
endsource;

tableExists = doesTableExist("casORA", "CONSENTIMIENTOS");
if tableExists=0 then do;
   /* Execute the DATA step code from the source block named myDataStep */
   dataStep.runCode result=r status=rc / 
	   code=myDataStep;
end;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Remember that, in CAS, tables written to the Oracle caslib (myOra) are still CAS in-memory tables, and have NOT been saved to the Oracle database yet. You must explicitly save it to the database, for example using the table.save action.&lt;/P&gt;
&lt;P&gt;May the SAS be with you!&lt;BR /&gt;Mark&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 03 Mar 2022 14:18:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/datastep-runcode-loading-from-oracle/m-p/799851#M314559</guid>
      <dc:creator>SASJedi</dc:creator>
      <dc:date>2022-03-03T14:18:11Z</dc:date>
    </item>
  </channel>
</rss>

