Reputation: 413
I have a large dateset where I need to dynamically create over 10 columns, however the amount of data makes for unnecessary long code blocks. Is is possible to simplify the code below, perhaps by using arrays?
Data have;
x1 = 1;
x2 = 2;
x3 = 3;
x4 = 4;
Run;
Data want;
Set have;
y1 = x1*2;
y2 = x2*2;
y3 = x3*2;
y4 = x4*2;
Run;
Upvotes: 0
Views: 105
Reputation: 4554
Define two arrays like this:
data want;
set have;
array varx x:;
array vary y1-y4;
do over varx;
vary=varx*2;
end;
run;
Upvotes: 0