BookmarkSubscribeRSS Feed
aroux
Calcite | Level 5

I am just learning SAS.  I am doing a simple problem for a statistics class using SAS 9.4 and have run into a problem that I do not understand the error message and how to resolve the error.  The proble is to create an inverse of a matrix.

 

The following is the code I used:

 

proc iml;

A={1 2, 2 -2, 3 10};

B=A`;

print A B;

run;

AB=A*B;

print AB;

run;

invAB=inv(AB);

print invAB;

run;

 

The following is the error message that I am receiving:

1    proc iml;

NOTE: Writing HTML Body file: sashtml.htm

NOTE: IML Ready

2    A={1 2, 2 -2, 3 10};

3    B=A`;

4    print A B;

5    run;

NOTE: Module MAIN is undefined in IML; cannot be RUN.

6

7    AB=A*B;

8    print AB;

9    run;

NOTE: Module MAIN is undefined in IML; cannot be RUN.

10

11   invAB=inv(AB);

ERROR: (execution) Matrix should be non-singular.

 

 operation : INV at line 11 column 10

 operands  : AB

 

AB      3 rows      3 cols    (numeric)

 

         5        -2        23

        -2         8       -14

        23       -14       109

 

 statement : ASSIGN at line 11 column 1

12   print invAB;

ERROR: Matrix invAB has not been set to a value.

 

 statement : PRINT at line 12 column 1

13   run;

NOTE: Module MAIN is undefined in IML; cannot be RUN.

 

I am using code that was supplied by the instructor (which worked).  I changed nothing with the instructor's code, but can not get a resolution. What am I doing wrong?

 

Thank you for your help

Thank you for your assistance.

3 REPLIES 3
arodriguez
Lapis Lazuli | Level 10

If I'm not mistaken, the determinant of the matrix is equal to 0, so it can not be inverted

Kurt_Bremser
Super User

The error with INV is described here: http://support.sas.com/documentation/cdl/en/imlug/63541/HTML/default/viewer.htm#imlug_langref_sect15...

 

You need to define modules in IML before you can RUN them, this causes the notes.

I don't know if it is good to dive into IML when you are just starting out with learning SAS, but you should at least take a thorough look at the SAS/IML documentation (SAS/IML Overview).

Ksharp
Super User
As LOG pointed out. Your matrix is singular. Such kind of matrix can't a inverse . ERROR: (execution) Matrix should be non-singular. And You'd better post it at IML forum, since it is IML code. And you don't need RUN in IML, but need a QUIT at the end of IML code.

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 3 replies
  • 2727 views
  • 1 like
  • 4 in conversation