BookmarkSubscribeRSS Feed
tomcmacdonald
Quartz | Level 8

I'm trying to join 17 tables together in SAS using PROC SQL and am running out of system resources.  All tables have a simple index on the joined field.  I'm thinking I can use the DATA STEP but I need to mimic COALESCE and left joins. 

6 REPLIES 6
Reeza
Super User

@tomcmacdonald wrote:

I'm trying to join 17 tables together in SAS using PROC SQL and am running out of system resources. 

 

Are you joining all in single query or multiple queries?

tomcmacdonald
Quartz | Level 8
In a single query.
tomcmacdonald
Quartz | Level 8

Now I'm trying to run the code in UNIX batch mode and specifying -MEMSIZE MAX and -WORK <some directory> system options.

Patrick
Opal | Level 21

@tomcmacdonald

In my experience SAS SQL is not great when trying to join many tables in a single SQL. Depending on what you want to do and especially what volumes and relationships between the tables you're dealing with, some tweaks to the SQL or a SAS data step can reduce resource consumption and/or improve performance a lot.

 

In case this is one big table with a lot of lookups (i.e. a fact table with dimension and reference tables) then using a SAS data step with hash lookup tables can be much more efficient. Logically left joins and coalesce() can also get implemented in a SAS data step.

Reeza
Super User
If it's a fact-dim reconstruction, I'm a fan of formats as well. They also tend to come in handy in other areas so you may even have them built already.
LinusH
Tourmaline | Level 20

The problem here is the left joins, since SAS (and other) can optimize the as god as inner joins.

Usually when creating star schemas, dimension values that are missing can be assigned a dummy value, like a dimsnion key -1. Then you can switch to inner joins.

If your data is in Base SAS libraries consider moving to SPDE, which has better index management and some additional use cases for index use in the where planner.

Data never sleeps

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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
  • 6 replies
  • 980 views
  • 0 likes
  • 4 in conversation