I want to replace values of some variables and rename them. Basically, I have many variables called f2 f3 f4 and so on up to f1065. The logic is as folllows: I need to replace values of variables f14 f18 and so on by 4 up to f54 by values of variables f2 f3 f4 up to f12. f13, f55 f56 and f57 are left as they are. Then I need to replace f70 f74 and so on by 4 up to f110 by values of f58 f59 up to f68. So f69 is unchanged. So I need to say SAS the following:
let k=2
do i=4 to 57 by 4;
f&i=f&k;
end;
k=&k+1;
and do this many times, so that the next time it will be
let k=58
do i=70 to 113 by 4;
f&i=f&k;
end;
k=&k+1;
How can I automise this task and possibly even delete the variables that I use for replacement (i mean variables like f2 f3 f4 ... f12). Thanks in advance!