BookmarkSubscribeRSS Feed
aamoen
Obsidian | Level 7
Hello - I'm trying to run the below code but its taking hours.  What can I do to improve the efficiency of this program so it doesn't take so long to run?
 
Thanks!
 
%let user = xxxxx;
%let pswd = "%STR({SAS002}EE9F3A145162A68C09E176074A3382401380A5B759B196C62EF8B5D5)";
 
libname here '/workspace/cucr/risk/userid/xxxxx';
 
proc sql;
options nomprint;
connect to oracle as adm (USER=&user. PASSWORD=&pswd. PATH="prod");
options mprint;
 
create table here.v_chd_mini_month_end (compress=yes) as select * from connection to adm
(select chd_open_date, tape_date, chd_credit_line, chd_account_number_ref, chd_cr_line_date
from adm.v_chd_mini_month_end
order by chd_account_number_ref, tape_date);
 
disconnect from adm;
quit;
8 REPLIES 8
SASKiwi
PROC Star

To see if the problem is a slow network between the Oracle and SAS servers try just getting a row count:

proc sql;
options nomprint;
connect to oracle as adm (USER=&user. PASSWORD=&pswd. PATH="prod");
options mprint;
 
create table here.v_chd_mini_month_end (compress=yes) as select * from connection to adm
(count(*) as row_count
from adm.v_chd_mini_month_end
);
 
disconnect from adm;
quit;

If this is slow, then talk to your Oracle DBA as it is Oracle that is slow, not SAS.

aamoen
Obsidian | Level 7

When I tried that I recieved the following err:

 

ERROR: ORACLE prepare error: ORA-24333: zero iteration count. SQL statement: count(*) as row_count from adm.v_chd_mini_month_end.

SASKiwi
PROC Star

Sorry, I forgot the SELECT in front:

select count(*) as row_count
AhmedAl_Attar
Rhodochrosite | Level 12

Hi @aamoen 

Have a look at these two papers

Here is what you need to pay attention to

- ReadBuff/BuffSize: How many Oracle Rows/Records are read for each fetch operation. Default:250 (Too-Little! --- Increase this if you can)

- SASTrace option: Tells you what's going on and where the query is running

- Oracle Hints: They could optimize Oracle execution, and speeds up your response times

 

Hope this helps,

Ahmed

Patrick
Opal | Level 21

I concur with others that the bottleneck is normally the data transfer from the database to SAS. In my experience increasing the value for readbuff is what often decreases elapsed time dramatically. The default value is almost always way too low.

s_lassen
Meteorite | Level 14

Your headline reads "Sorting large dataset" - have you tried not having Oracle sort the data (drop the ORDER BY clause), and sort in SAS afterwards. If it is the actual Oracle server (and not the connection) which is slow, that may help on the performance. But I would probably try looking at the connection options first.

LinusH
Tourmaline | Level 20

My question is how you intend to use the result table?

The general idea is to keep large tables in the source until you need them for your final step. In this case you might continue with filtering, joining and what not.

Be aware of that SQL implict passthrough automatically sorts your data if the database libname engine encounters a BY statement (PROC, data step etc).

Data never sleeps

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 8 replies
  • 1050 views
  • 4 likes
  • 7 in conversation