Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

- RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page

🔒 This topic is **solved** and **locked**.
Need further help from the community? Please
sign in and ask a **new** question.

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

Posted 02-28-2020 11:22 AM
(519 views)

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

1 ACCEPTED SOLUTION

9 REPLIES 9

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

The advantage of using a SAS data set is that it is not an Excel file. But maybe you have something else in mind?

--

Paige Miller

Paige Miller

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

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?

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

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.

--

Paige Miller

Paige Miller

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

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?

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

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_...

--

Paige Miller

Paige Miller

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

Nice one mate. That was very useful. Now my data matrices are looking so much better.

Thanks you very much,

DJ

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

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.

Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.

**If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website. **

Multiple Linear Regression in SAS

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.