Marilyn,
To follow-up on Scott's comments, Rick Langston has a paper that works with look-up techniques:
http://support.sas.com/resources/papers/proceedings09/037-2009.pdf
It looks like you just have 20 files to examine. It may be easier to hard-code the concatenation than to build the looping code.
The ARRAY approach is the easiest way to go through the 10 diagnosis coded. In the loop, set a flag for the exclusion; outside the loop, examine the flag to decide to output the record or not.
Your expressed request, and this approach, will NOT exclude persons with these diagnoses on ANY encounter. To do that, output an ID list of the subset with the diagnosis on any encounter and re-merge that with the original set of hits. That is an easy SQL code:
SELECT * FROM keepers
WHERE ssn NOT IN (SELECT DISTINCT ssn FROM excludes)
Doc Muhlbaier
Duke