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

Hi everyone!

I am trying to define a three dimensional array with proc iml. Currently I am converting a matlab code to SAS so that I need to deal with matrices a lot. Is there any known way to define a 3d array /matrix?

1 ACCEPTED SOLUTION

Accepted Solutions
IanWakeling
Barite | Level 11

One way is to use a list of ordinary 2d matrices.  For example the code below creates a list of 3 4x4 matrices, then modifies two of them.

proc iml;
  Z = ListCreate(3);
  do i = 1 to 3;
    Z$i = i(4);
  end;
  Z$2 = Z$2 + 1;
  Z$3 = Z$3 # 3;

  package load listutil;
  call listprint(Z);
quit;

View solution in original post

1 REPLY 1
IanWakeling
Barite | Level 11

One way is to use a list of ordinary 2d matrices.  For example the code below creates a list of 3 4x4 matrices, then modifies two of them.

proc iml;
  Z = ListCreate(3);
  do i = 1 to 3;
    Z$i = i(4);
  end;
  Z$2 = Z$2 + 1;
  Z$3 = Z$3 # 3;

  package load listutil;
  call listprint(Z);
quit;

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
  • 1 reply
  • 368 views
  • 7 likes
  • 2 in conversation