I realise that I am answering an old question and the user may have moved on. I am adding my code in answer to this question. The writing in BOLD is how one gets the number of columns that have a certain prefix. Data work.temp2 ; set work.tableappend; by Visitlink; array diaggg {*} diag: ; /* dynamically set the number of Diag columns from input table*/ array diag{*} diag:; /* Creating an array of length of the number of diag columns in input table */ LENGTH j 3.; j = 1; do until ( j > dim(diaggg)); diags = diag[j]; /* This only takes dX codes. Creates new CHAR column name diags */ j = j + 1; IF diags NE . THEN OUTPUT;; /* This put each code on a separate line. */ end; run;
... View more