Hi, I want to process a comma-separated list of values in a variable (e.g., Q8) and create corresponding response variables (Q8_1, Q8_2, ..., Q8_17). For each value in the list, I want to set the corresponding response variable to 1 if there is a value. If the value is missing, the corresponding response variable should remain blank. Here is an example of what the variable initially looks like: Q8 11 . . . 15,17 . 11,12,13,14,15 1,2,3,4,5,6,7,8,9,10 11 I tried something like this, but it's not accounting correctly for values 10+. any suggestions? I am not married to this code, so if someone has a completely different one, I am okay with that. data numeric2; set numeric; run; %macro initial2(var, num); data numeric2; format &var._1 - &var._&num 8.; set numeric2; run; %mend; %macro pop_var(var, num); data numeric2; set numeric2; if index(&var, "&num")>0 then &var._&num = 1; run; %mend pop_var; %macro run_pop(var2, num2); %initial2(&var2, &num2); %do i = 1 %to &num2; %pop_var(&var2, &i); %end; %mend; %run_pop(Q8, 17);
... View more