Hi, thanks for the responses. I need a loop, (maybe not a macro) as there will be multiple fields all with COL at the beginning. data have; input Parameter $ COL1 $ COL2 $; cards; Intercept AGE DRINKPATTERN DRINKPATTERN AGE DRINKPATTERN DRINKPATTERN AGE DRINKPATTERN DRINKPATTERN AGE DRINKPATTERN DRINKPATTERN AGE DRINKPATTERN FISHLASTWEEK AGE DRINKPATTERN AGE AGE DRINKPATTERN AGE AGE DRINKPATTERN AGE AGE DRINKPATTERN FISHLASTWEEK*AGE AGE DRINKPATTERN FISHLASTWEEK*AGE AGE DRINKPATTERN FISHLASTWEEK*AGE AGE DRINKPATTERN ; run; Using the data above, I can create a new field using a data step with the following: data want; set have; Type = 1; if index(Parameter, col1 ) NE 0 then Type = 2; run; I would like this to run in a loop and replace the col1 with col2 etc the output should have an additional field TYPE that has a value of 2 if the strings in col1 or col2 are found in the field parameter: Parameter Col1 Col2 Type Intercept AGE DRINKPATTERN 1 DRINKPATTERN AGE DRINKPATTERN 2 DRINKPATTERN AGE DRINKPATTERN 2 DRINKPATTERN AGE DRINKPATTERN 2 DRINKPATTERN AGE DRINKPATTERN 2 FISHLASTWEEK AGE DRINKPATTERN 1 AGE AGE DRINKPATTERN 2 apologies for omissions previously, I will try the macro with the array, thank you
... View more