Thanks @Rick_SAS. That works for reading the names from the file. However, I'm not being able to do the residual bit (assign 1 - sum of row to the elements as mentioned in the parametrisation table). Please find my code with data steps: data param_table;
infile datalines dsd;
length FieldName $20 FieldSourceTable $20;
input Matrix_Id Column_Order Row_Order IsZero IsRowResidual IsColumnResidual FieldName FieldSourceTable;
datalines;
1, 1, 1, 0, 1, 0, ., .
1, 1, 2, 0, 0, 0, xyz, table1
1, 1, 3, 0, 0, 0, abc, table1
1, 2, 1, 1, 0, 0, ., .
1, 2, 2, 0, 0, 0, pqr, table1
1, 2, 3, 0, 0, 0, mno, table1
1, 3, 1, 0, 0, 0, ab, table1
1, 3, 2, 0, 0, 0, pq, table1
1, 3, 3, 0, 1, 0, ., .
;
data table1;
input Year (country method Segment) ( : $12.)
ABC XYZ PQR MNO AB PQ;
datalines;
2017 France ABC Retail 0.2 0.5 0.4 0.3 0.6 0.1
2017 France XYZ Corporate 0.1 0.5 0.4 0.2 0.6 0.2
;
run;
proc iml;
/*varNames = {"Matrix_ID" "Column_Order" "Row_Order" "FieldName" "IsRowResidual" "IsColumnResidual" "FieldSourceTable"};*/
use param_table; /* parameterization table */
read all var _all_;
close;
idx = loc(FieldName ^= " ");
rowsumx = loc(IsRowResidual=1);
refNames = FieldName[idx];
rows = Row_Order[idx];
cols = Column_Order[idx];
row_res = Row_Order[rowsumx];
col_res = Column_Order[rowsumx];
create residual var {row_res col_res};
append;
use residual;
read all var _all_ into res_mat;
close;
a = res_mat[,1];
b = res_mat[,2];
print idx,rows cols refNames;
use Table1;
read all var refNames into Y;
close;
PRINT Y,
do i = 1 to nrow(Y);
X = j(3,3,0);
X[idx] = Y[1,];
rowsum = X[,+];
temp = J(3,1)- X[,+];
** X[a,b] = temp[a,1]; /**----------- trying to assign the (a,b) th element to be (1 - sum of all the elements in ath row) **/
end;
print X;
end; Appreciate your help!
... View more