@chemph: Now you've got three solutions. If you go for a PROC SQL approach, I would recommend @Ksharp's, because it's more elegant than mine. (It lets PROC SQL perform the join of grouped and original data automatically.) Please note that his definition of TOS_CAT2_CD is slightly different from the definition used in the other two suggestions: He requires all observations with the same INT_CLM_NUM to have TOS_CAT1_CD='FAC_IP', whereas in the other approaches a single occurrence of 'FAC_IP' in that group of observations would trigger the "MATER" designation for the group. But this could be adapted easily by deleting "=count(*)" in the WHEN condition. Also, an ORDER BY clause (as in my code) could be added to sort the output dataset.
@Astounding's DOW loop approach would need only a minor adaptation if it were to work with grouped, but unsorted input data (like 888... before 777...): You would just need to add the NOTSORTED option to the two BY statements: by int_clm_num notsorted;. As a benefit, it would maintain the same sort order in the output dataset (unlike PROC SQL).
... View more