I have a table with 141 columns. I need to look through 25 specific columns that list a patients diagnosis (Diag1-Diag25). Each column has a single diagnosis code in it which is in character form. I have a list of specific diagnosis codes that I'm interested in and I want to keep any row that has these diagnosis codes in any of the Diag1-Diag25 columns in my filtered.I have done this successfully; however, my approach is very inefficient and does not scale well. Right now my best approach consists of using a PROC SQL statement with a CREATE TABLE and WHERE statement to individually specify each column I want to look at. Then I have to use an IN statement to specify the range of diagnostic codes I'm interested in and join each individual column analysis with an OR statement. Here is an example of my code: proc sql noprint; create table SUBGROUP as select * from FILE.UNFILTERED_TABLE where(Diag1 IN("4275") OR Diag2 IN("4275") OR Diag3 IN("4275") OR Diag4 IN("4275") OR Diag5 IN("4275") OR Diag6 IN("4275") OR Diag7 IN("4275") OR Diag8 IN("4275") OR Diag9 IN("4275") OR Diag10 IN("4275") OR Diag11 IN("4275") OR Diag12 IN("4275") OR Diag13 IN("4275") OR Diag14 IN("4275") OR Diag15 IN("4275") OR Diag16 IN("4275") OR Diag17 IN("4275") OR Diag18 IN("4275") OR Diag19 IN("4275") OR Diag20 IN("4275") OR Diag21 IN("4275") OR Diag22 IN("4275") OR Diag23 IN("4275") OR Diag24 IN("4275") OR Diag25 IN("4275")); quit; This is the most simple example where I only care about 1 diagnostic code but sometimes I need to look at 30 codes which makes this approach kind of cumbersome. I have tried to find a way to reference multiple columns in SAS in a DATA step or using looping and such but nothing has worked for me so any advice/help would be greatly appreciated.
... View more