I have problem with Multidimensional Array. I created calculate between two types of data from one table. Example data from table BT_MATRYCA. And I division data from TYP: VAL_A since COL1 to COL17 by value from SUMA_RAZEM from row with TYP: VAL_B.
Command "put d_st[i,j] =;" puts good value but I need create table with this calculate (Multidimensional, with X and Y). How I can do?
data BT_MATRYCA;
infile DATALINES dsd missover;
input NAME $ TYP $ COL1 COL2 COL3 COL4 COL5 COL6 COL7 COL8 COL9 COL10 COL11 COL12 COL13 COL14 COL15 COL16 COL17 SUMA_RAZEM;
CARDS;
A1, VAL_A, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 500
A1, VAL_B, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 600
B1, VAL_A, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 12, 13, 14, 15, 16, 16, 20, 550
B1, VAL_B, 1, 20, 3, 20, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 800
C1, VAL_A, 20, 2, 3, 4, 5, 6, 7, 8, 9, 10, 30, 12, 13, 14, 15, 16, 17, 900
C1, VAL_B, 1, 2, 3, 20, 5, 6, 7, 8, 02, 10, 11, 12, 30, 14, 15, 16, 17, 780
;run;
data t3;
array m[6,18] _temporary_;
array n[6,18] _temporary_;
array d_st[6,18] _temporary_;
call missing(of d_st[*]);
if _n_ = 1 then do;
do i = 1 by 1 until(z1);
set BT_MATRYCA (where=(TYP = 'VAL_A')) end = z1;
array c[18] COL1--SUMA_RAZEM;
do j = 1 to 18;
m[i, j] = c[j];
end;
end;
do i = 1 by 1 until(z2);
set BT_MATRYCA (where=(TYP = 'VAL_B')) end = z2;
array v[18] COL1--SUMA_RAZEM;
do j = 1 to 18;
n[i,j] = v[j];
end;
end;
end;
do i = 1 to 6;
do j = 1 to 18;
IF m[i,18] ne 0 then
d_st[i,j] = coalesce((n[i,j] / m[i,18]),0);
ELSE
d_st[i,j] = 0;
end;
end;
do i = 1 to 6;
do j = 1 to 18;
put d_st[i,j] =;
end;
end;
stop;
run;
`
OUTPUTstatements so that your records get written out to the data set.