I have a toy dataset:
data step1;
input var1 - var16;
datalines;
25000 26000 27000 28000 29000 30000 31000 32000 0.45 0.25 0.35 0.60 0.75 0.29 0.45 0.51
;
run;
i'm trying to create new variables. One way is to do it individually i.e
var17 = var1 - D*var9;
var18 = var1 - D*var10;
var19 = var2 - D*var11;
..
..
But it is time intensive and prone to mistake. I want to use multi-dimensional array. I ran the following code.
The code to create new variable is:
data step2;
set step1;
array A{2,2,2} var9-var16;
array C{2,2,2,4} var17 - var48;
array B{2,4} var1-var8;
D = 250;
do f = 1 to 4;
do i = 1 to 2;
do j = 1 to 2;
do m = 1 to 2;
C{i,j,m,f} = B{j,f} - D*A{i,j,m};
output;
end;
end;
end;
end;
stop;
run;
The code this time runs but gives me 32 rows.But i want the new variables created in one row only. What is wrong then? Is there any other way to achieve my objective? I'm using SAS 9.4