BookmarkSubscribeRSS Feed
Abyt
Calcite | Level 5

How to create idempotent matrix in sas/IML

6 REPLIES 6
PeterClemmensen
Super User

Any idempotent matrix?

Abyt
Calcite | Level 5
Thank you for your response. I need SAS/IML code to generate any idempotent matrix.
PeterClemmensen
Super User

Moved this thread to the IML Forum.

SAS_Rob
SAS Super FREQ

One way to generate an idempotent matrix is to use the formula:
M=I-(1/n)*ii`

where I is the identity matrix, n is the number of rows, and i is a column vector of 1s of dimension n.

This matrix is by definition orthogonal so that the rows are independent.  

I have included an example below of how this can be done in IML.

proc iml;
n=5;
i=j(n,1,1);
M=i(5)-((1/n)*i*i`);
m2=m*m;*check for idempotency;
print m m2;
quit;

Rick_SAS
SAS Super FREQ

To create a matrix in SAS/IML, use curly brackets to begin/end the matrix. Use spaces to separate columns and use commas to indicate a new row. For example:

proc iml;

A = { 1  0,
        0   1};
Rick_SAS
SAS Super FREQ

If your question is answered, please mark an answer as "Accepted" and mark the question as "Resolved." Otherwise, please let us know what additional information you need.

SAS INNOVATE 2024

Innovate_SAS_Blue.png

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. 

Register now!

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.

From The DO Loop
Want more? Visit our blog for more articles like these.
Discussion stats
  • 6 replies
  • 496 views
  • 5 likes
  • 4 in conversation