Hi,
I have been using SAS/IML for few months now. I would like to use different sets of data to undertake some calculations related to Experimental Designs, the only way I am aware of is to import the data from an excel file to be then read into arrays in sas/iml. This way of importing data is making some of the calculations very hard.
Does anyone know the different ways of setting the data to be used particularly in SAS/IML.
I want to save different sets of data in files and call them into SAS/IML. Is that possible?
Thanks,
DJ
Is it read and used in a similar way as data from an excel file. Is there any advantages of using the SAS data set?
The advantage of using a SAS data set is that it is not an Excel file. But maybe you have something else in mind?
Thanks for your reply.
I had hope that using a different method to import data will make some calculations easier to tackle.
Right now, first I have to import the data from excel then read and assign each column to an array separately. Is there a way to put the whole data set in a matrix at once?
Yes you can read an entire SAS data set into PROC IML as a matrix. Please look at the examples in the documentation that I linked to.
Thank you very much.
I managed to read all the variables into a matrix however I had to read the numerical _NUM_ and character _CHAR_ variables separately even though I tried using _ALL_ to print all variable into one matrix but its not working. Are you aware of any reasons that can cause such a problem?
Also, is it possible to read the headings of the columns from excel as well?
Character variables and numeric variables need to be in separate matrices. In PROC IML, you have to refer to a matrix by its matrix name, I don't think you can refer to specific columns by some other name. So maybe most of the data goes into one matrix, and another part of the data goes into a different matrix, allowing you to have somewhat meaningful matrix names.
You can change the way matrices are display, to have meaningful column names, but that only affect the display of the matrices and not calculations done with the matrices. https://documentation.sas.com/?cdcId=pgmsascdc&cdcVersion=9.4_3.4&docsetId=imlug&docsetTarget=imlug_...
Nice one mate. That was very useful. Now my data matrices are looking so much better.
Thanks you very much,
DJ
For an overview, see "Reading ALL variables INTO a matrix."
Paige said, "I don't think you can refer to specific columns by some other name," but that is not actually correct. You can access rows or columns of a matrix by names. However, maybe what Paige meant is that this feature is not always useful in complex programs, which is an opinion that I agree with.
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.