Hi,
I am having an oracle error as my source table is in oracle DB and the count of that table is more than 4,294,967,296. That is not supported in my current version but i need to submit my delivery on time.
so can you help me that if there are 4400000000 total records in dataset A ( table in oracle) and i want my first 4000000000 to be in dataset B from dataset A and rest 294,967,296 record in dataset C .
and in last i will append dataset B and dataset C to process further. Can you help me with the bold part? above thanks !!
Do you want to have it in SAS or in Oracle?
In sas you can use firstobs= and obs= dataset options:
data A;
do i = 1 to 10;
output;
end;
run;
data B;
set A (obs=7);
run;
proc print;
run;
data C;
set A (firstobs=8);
run;
proc print;
run;
But when you are pulling data from a data base I'm not sure if the data order is guaranteed.
Maybe if there is some sort of primary key which can allow to select all values less than "some value" to the first set and then all greater than equal from that "value" to the other set.
All the best
Bart
Do you really want to transfer 4 billion observations from SAS to Oracle? Why? How often do you need to refresh that data? What's the expected runtime?
If the limit you have is because you use a 32-bit platform, this kind of volume seems much too large.
The trouble is that Oracle may not always send the data in the same order, so if you can't use data values to determine the output table, you need to do this in one step:
data B C;
set A;
if _N_<=4e9 then output B; else output C;
run;
So you need to create two separate tables in Oracle to accommodate the limits there?
Create a LIBNAME to the Oracle DB and schema, then run a variation of @ChrisNZ 's code:
data
oracle.B
oracle.C
;
set A;
if _N_ <= 4e9
then output oracle.B;
else output oracle.C;
run;
If you can't even open the table from SAS to SET it in a data step, then you need to split it on the Oracle side.
This will need to be done in SQL.
I would define two views and use a variable along which you can easily split the data, like a transaction date or so.
Then, read the views separately.
Consult the Oracle documentation for CREATE VIEW (that's what I would also need to do). Furthermore, get in touch with your Oracle admins with regards to the necessary permissions and other technical details.
@librasonali wrote:
my source table is in ORACLE and SAS is not able to read such many observation...
There is not such limit to my knowledge. What is your statement based on? Do you get a timeout or the like?
Oracle doesn't have a concept of row numbers and furthermore the only way to ensure Oracle returns rows always in the same order is to use an order by statement.
The normal approach is to reduce data volumes on the DB side prior to transferring it into SAS. The transfer from the DB to SAS is the likely bottleneck and could take a long time to run.
Do you really need the full table with all the detail on the SAS side or could you first reduce volumes on the DB side (like some selection for only specific values or pre-aggregation)? You can run SQL code on the DB side out of SAS and then only download the result set.
If you really need the full table then something like a bulkunload will likely perform much better. Downloading the full table will also require the necessary disk space to be available.
@Reeza is also hinting at other a bit more advanced options like Oracle partitions that - if the Oracle table is created this way - would allow to directly address the partitions and download in "chunks". ...but first look into processing on the Oracle side to reduce volumes prior to loading anything into SAS.
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.