With all due respect, I don't think you have fully explained your use case so we can offer the most effective advice. If appears you are joining a SAS dataset with a Teradata table. Since you appear to be using just 'normal' SQL this will execute on your SAS server and means ALL Teradata data will have to read onto your SAS server before the join can happen. Please correct my assumptions here if they are not correct.
A much better and way faster strategy would be to upload your SAS dataset into a temporary Teradata table and do ALL of your joining in Teradata, then reading the new table back to SAS. This is going to require use of SQL Passthru - have you used this before?
... View more