BookmarkSubscribeRSS Feed
lawatkey
Obsidian | Level 7

I am trying to run some programs against a large table with many indices (that I do not have control over).  Is there a way to have SAS just choose 1 index, like you can in SQL?   And is it possible that this makes a program more efficient, or is this just a waste of time?

4 REPLIES 4
lawatkey
Obsidian | Level 7

IDXNAME= didn't work on my table but I did a proc contents and realized the SQL indices were not translating over to the SAS table 🙂  
Sort of a side question, but is it possible to create an index on a table you can't make any changes to?   But in terms of the original question, your solution was spot on so thank you very much!

Reeza
Super User
This depends on how you're connecting and viewing the data. After you extract the data you won't have any indexes. But SAS should use the DB indexes if they exist. If you really want to make it efficient explicit SQL pass through is likely your best bet, as you can use the native language and the indexes as desired. Implicit works fairly well, you can have the log show the full information of the SQL code so that you can see if the indexes are used. There's ways to do all of this in SAS but I can't remember the exact code but maybe @yabwon does 😉
yabwon
Onyx | Level 15

As @Reeza suggested you could use pass through, syntax is more or less as follows (but do check documentation for the details):

proc sql;
  /* start connection to some database <engine> e.g. Teradata, Oracle, Postgers */
  connect to <ENGINE> as DB (user="user" password="password" database="database" server="123.123.123.123");


  create table WORK.LOCAL AS /* create local table */
      (
      select * from connection to DB /* with pass through to database with databale native SQL */
          (
              select A.id, A.x, B.y 
              from Exteranal1 A 
              join External2 B 
              on A.id = B.id
          )
      );

  disconnect from BD;
quit;

Bart

_______________
Polish SAS Users Group: www.polsug.com and communities.sas.com/polsug

"SAS Packages: the way to share" at SGF2020 Proceedings (the latest version), GitHub Repository, and YouTube Video.
Hands-on-Workshop: "Share your code with SAS Packages"
"My First SAS Package: A How-To" at SGF2021 Proceedings

SAS Ballot Ideas: one: SPF in SAS, two, and three
SAS Documentation



SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 4 replies
  • 651 views
  • 2 likes
  • 3 in conversation