In line with @andreas_lds:
data have;
input accid $4. branch $25.;
datalines;
1001 pune,hyderabad,banglore
1002 haryana,delhi
1003 shimla
;
run;
data want (drop = branch i);
set have;
do i = 1 to countw(branch, ","); /* i becomes a counter for the commas */
_branch = scan(branch, i, ","); /* notice the i becomes the <count> argument in the SCAN function. The loop iterates over the number of commas.*/
output; /* Output each separate branch before returning to top of loop. */
end;
run;
accid _branch
1001 pune
1001 hyderabad
1001 banglore
1002 haryana
1002 delhi
1003 shimla
... View more