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-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

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
  • 4 replies
  • 462 views
  • 2 likes
  • 3 in conversation