In an IML procedure I have a matrix with named columns.
proc iml;
myMatrix = {1 2 3, 1 4 9};
mattrib myMatrix colname={"a", "b", "c"};
print myMatrix;
print (myMatrix[,"a"]);
/* load module = myModule;*/
/* run myModule(myMatrix);*/
run;
I can easily access and print the columns by name. However, when I pass the matrix to a user defined module, the column names inside the module disappear (to run the module uncomment the lines in previous proc iml)
proc iml;
start myModule(MatrixWithHeader);
print MatrixWithHeader;
print (MatrixWithHeader[,"a"]);
finish myModule;
store module=myModule;
run;
I got the following error:
ERROR: (execution) Character argument should be numeric.
How can I access the matrix columns in the module by their names?
Access by column number will make the code inflexible. Possible workaround might be to pass the vector of column names as an argument and run a mattrib inside the module. However, repeat of mattrib is cumbersome and in this case I will need to extract colnames from the myMatrix, since it is defined by a long piece of code (not like in example), and the vector of names is not available.
Thanks in advance,
Alex
SOLVED
Thanks for the solution.