Hello.
I want to read a dataset with two columns into proc iml, but it only prints one column when I print it.
Can someone tell me what I am doing wrong please?
proc iml; use data.lossdata; read all var {lob loss} into A[colname = varNames]; print A; quit;
You can read the variables into vectors:
read all var {lob loss};
For more information about reading numeric and character variables, see
These two variables have the same type ? both are numeric or character ?
The lob is a character and loss numeric.
@Ksharp has diagnosed the problem correctly, as matrices are either all character or all numeric. Whenever you run code, it is always good to check the SAS log for messages, as I suspect you have missed a warning message about a type missmatch.
Also check the recent thread on this forum called "Matrix with strings in IML", in particular the link that Rick gives to the Table structure.
You can read the variables into vectors:
read all var {lob loss};
For more information about reading numeric and character variables, see
Thank you all.
I appreciate the help.
There is still a lot to learn.
Yes, there is always more to learn, but to get started you might try some of the tips at "Ten tips for learning the SAS/IML language", especially the SAS Global Forum paper "Getting Started with the SAS/IML Language" (Wicklin 2013)
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 16. Read more here about why you should contribute and what is in it for you!
Learn how to run multiple linear regression models with and without interactions, presented by SAS user Alex Chaplin.
Find more tutorials on the SAS Users YouTube channel.