<?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: Load last n obs from oracle in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Load-last-n-obs-from-oracle/m-p/854623#M337771</link>
    <description>&lt;P&gt;Thanks, the "solution" I've found is to sort the oracle table in the data step, in this case the start date of the contracts.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The loading time for these tables is quite ok, I do not complain for the medium size tables up 2 million rows.&lt;/P&gt;
&lt;P&gt;Having 20 million rows slows down a lot and normally I only need the last year's data.&lt;/P&gt;
&lt;P&gt;This approach improves my situation at least.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data MKT.aki(promote=no);
set myora.fact_ope_form(obs=10000);
by descending fecformo;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Thu, 19 Jan 2023 16:10:44 GMT</pubDate>
    <dc:creator>acordes</dc:creator>
    <dc:date>2023-01-19T16:10:44Z</dc:date>
    <item>
      <title>Load last n obs from oracle</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Load-last-n-obs-from-oracle/m-p/854544#M337725</link>
      <description>&lt;P&gt;The attached code works, but it takes as long time as reading all the oracle rows.&lt;/P&gt;
&lt;P&gt;I want him to START reading at row 10000000 like the firstobs option tells him.&amp;nbsp;&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 dbcon
       (user=SAS password='xxxxxxxx' buffsize=100
        PATH=xxxxxx.vwfsag.de);
select * into :noby
   from connection to dbcon
     ( select 
          count(*)  from fact_ope_form);
quit;

%put &amp;amp;noby.;
%let numobs=100;

data _null_;
f1=&amp;amp;noby. - &amp;amp;numobs;
call symputx("first_o", f1);
call symputx("last_o", &amp;amp;noby.);
run;

%put &amp;amp;first_o. &amp;amp;last_o.;

data MKT.aki(promote=no);
set myora.fact_ope_form(obs=&amp;amp;last_o. firstobs=&amp;amp;first_o.);
keep fec: _fec: dummy;
_fecformo=datepart(fecformo);
dummy=1;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 19 Jan 2023 11:54:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Load-last-n-obs-from-oracle/m-p/854544#M337725</guid>
      <dc:creator>acordes</dc:creator>
      <dc:date>2023-01-19T11:54:49Z</dc:date>
    </item>
    <item>
      <title>Re: Load last n obs from oracle</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Load-last-n-obs-from-oracle/m-p/854621#M337769</link>
      <description>&lt;P&gt;Is your set&lt;/P&gt;
&lt;PRE class="language-sas"&gt;&lt;CODE&gt; myora.fact_ope_form&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;actually an Oracle table connected to SAS?&lt;/P&gt;
&lt;P&gt;Have you looked to see if Oracle supports such an action? Doing it with pass through and native Oracle tools would likely run much quicker. As a minimum I would look to using Oracle dictionary tables, or equivalent, to query the data base for details about the number of records in the set instead of using the Count(*) which would load the entire set to get a piece of information likely stored elsewhere in the Oracle system.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;NOT an Oracle guru, so don't know the exact place to look.&lt;/P&gt;</description>
      <pubDate>Thu, 19 Jan 2023 16:03:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Load-last-n-obs-from-oracle/m-p/854621#M337769</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2023-01-19T16:03:37Z</dc:date>
    </item>
    <item>
      <title>Re: Load last n obs from oracle</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Load-last-n-obs-from-oracle/m-p/854622#M337770</link>
      <description>&lt;P&gt;SQL databases don't reinforce row order, so reading by location can be tricky. Is there another way of specifying this condition instead?&lt;BR /&gt;&lt;A href="https://asktom.oracle.com/pls/apex/asktom.search?tag=operations-preserving-row-order" target="_blank" rel="noopener"&gt;https://asktom.oracle.com/pls/apex/asktom.search?tag=operations-preserving-row-order&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;all_table is the dictionary table in Oracle and num_rows has the number of rows.&lt;/P&gt;
&lt;P&gt;&lt;A href="https://dataedo.com/blog/useful-oracle-data-dictionary-queries-every-dba-should-have" target="_blank"&gt;https://dataedo.com/blog/useful-oracle-data-dictionary-queries-every-dba-should-have&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 19 Jan 2023 16:11:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Load-last-n-obs-from-oracle/m-p/854622#M337770</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2023-01-19T16:11:33Z</dc:date>
    </item>
    <item>
      <title>Re: Load last n obs from oracle</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Load-last-n-obs-from-oracle/m-p/854623#M337771</link>
      <description>&lt;P&gt;Thanks, the "solution" I've found is to sort the oracle table in the data step, in this case the start date of the contracts.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The loading time for these tables is quite ok, I do not complain for the medium size tables up 2 million rows.&lt;/P&gt;
&lt;P&gt;Having 20 million rows slows down a lot and normally I only need the last year's data.&lt;/P&gt;
&lt;P&gt;This approach improves my situation at least.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data MKT.aki(promote=no);
set myora.fact_ope_form(obs=10000);
by descending fecformo;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 19 Jan 2023 16:10:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Load-last-n-obs-from-oracle/m-p/854623#M337771</guid>
      <dc:creator>acordes</dc:creator>
      <dc:date>2023-01-19T16:10:44Z</dc:date>
    </item>
    <item>
      <title>Re: Load last n obs from oracle</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Load-last-n-obs-from-oracle/m-p/854657#M337789</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/127222"&gt;@acordes&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Having 20 million rows slows down a lot and normally I only need the last year's data.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If there is anything resembling a DATE valued variable in the data then a WHERE clause in data selection should get you "last year's data". Implement that correctly and it should reduce times a lot.&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;</description>
      <pubDate>Thu, 19 Jan 2023 19:03:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Load-last-n-obs-from-oracle/m-p/854657#M337789</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2023-01-19T19:03:49Z</dc:date>
    </item>
  </channel>
</rss>

