Hello, I'm looking for a solution to create new variables using a do loop. The names of the new variables should include the index of the do loop. Here's my example code: data have;
input M Q;
datalines;
1 10
2 30
;
data want;
set have;
do i = 1 to 2;
if M=i then QM_i=Q;
else QM_i=0;
end;
run; Of course, the program does only generate one new variable QM_i (besides the index variable i) because it does not recognize the index i in the variable name: M Q i QM_i 1 1 10 3 0 2 2 30 3 30 Rather, I would like to get: M Q i QM_1 QM_2 1 1 10 3 10 0 2 2 30 3 0 30 Any help is greatly appreciated!
... View more