I have one row per patient and for each row I have up to 10 ICD codes (each code is a variable/column, e.g. ICD1, ICD2, ..., ICD10) and corresponding ICD text for each of the codes. I am interested in identifying, for each patient, the ICD9 code(s) that match any of the codes that I have from a master list of codes. Then I want to create a new variable, for each row, that contains the codes that matched along with the corresponding text.
Is this an issues that can be managed using an array?
An array could be used to parse through the ICD codes and using a SAS format and a PUT function to compare each ICD variable against your master list of codes. Then as you process through the ICD codes, if you find a match by using the test, such as
MATCH = PUT(ICD,$icd_master.);
Then you append each of the matching codes to a new combined-matching-values variable that are in your master list.
So, I prefer to build the $icd_master format with SAS PROC FORMAT, and as shown using the PUT function to test for a match. Using a SAS format for the master list is more flexible for DATA step processing in my opinion.