Statistical programming, matrix languages, and more

NORM function in PROC IML

Accepted Solution Solved
Reply
Contributor
Posts: 46
Accepted Solution

NORM function in PROC IML

I'm not sure why I get the following error when I run the code that follows:

ERROR: Invocation of unresolved module NORM.

proc iml;

x = {1 2, 3 4};

print x;

mn1 = norm(x, "L1");

mnF = norm(x, "Frobenius");

mnInf = norm(x, "LInf");

print mnF;

print mn1;

run; quit;


Accepted Solutions
Solution
‎11-14-2012 06:24 PM
SAS Super FREQ
Posts: 3,399

Re: NORM function in PROC IML

That function was introduced in SAS/IML 12.1 (SAS 9.2M2). You must be running an earlier version.

However, those functions are simple to program. Here they are:

proc iml;


start matnorm(x, method);
   s = substr(upcase(method), 1, 4);
   isValid = (s="FROB" | s="L1" | s="LINF");
   if ^isValid then return(.);
  
   if (s="FROB") then do;
      return( sqrt(x[##]) );
   end;
   else if (s="L1") then do;
      return( max(x[+,]) );
   end;
   else if (s="LINF") then do;
      return( max(x[,+]) );
   end;
finish;

x={1 2, 3 4};
mn1 = matnorm(x, "L1");
mnF = matnorm(x, "Frobenius");
mnInf = matnorm(x, "LInf");
print mn1 mnF mnInf;

View solution in original post


All Replies
Solution
‎11-14-2012 06:24 PM
SAS Super FREQ
Posts: 3,399

Re: NORM function in PROC IML

That function was introduced in SAS/IML 12.1 (SAS 9.2M2). You must be running an earlier version.

However, those functions are simple to program. Here they are:

proc iml;


start matnorm(x, method);
   s = substr(upcase(method), 1, 4);
   isValid = (s="FROB" | s="L1" | s="LINF");
   if ^isValid then return(.);
  
   if (s="FROB") then do;
      return( sqrt(x[##]) );
   end;
   else if (s="L1") then do;
      return( max(x[+,]) );
   end;
   else if (s="LINF") then do;
      return( max(x[,+]) );
   end;
finish;

x={1 2, 3 4};
mn1 = matnorm(x, "L1");
mnF = matnorm(x, "Frobenius");
mnInf = matnorm(x, "LInf");
print mn1 mnF mnInf;

Esteemed Advisor
Posts: 7,288

Re: NORM function in PROC IML

: Did you mean 9.3M2?  I'm running SAS/OR 9.3_M1 (thus don't have 12) and they don't work for me either.

SAS Super FREQ
Posts: 3,399

Re: NORM function in PROC IML

Yes. Sorry for the typo. 12.1 is the most recent release of 9.3.

Contributor
Posts: 46

Re: NORM function in PROC IML

THat's what I'll do. As a side note, I have SAS 9.3 TS1MO. I'm not sure what version of SAS IML I actually have.

Contributor
Posts: 46

Re: NORM function in PROC IML

Thanks again Rick. I've run into this issue because I'm actually playing around with some SNA stuff. I'm also looking at incorporating some of your code from your post: The power method: compute only the largest eigenvalue of a matrix - The DO Loop

SAS Super FREQ
Posts: 3,399

Re: NORM function in PROC IML

Right. Notice in that post I used the statement

   normZ = sqrt( z[##] );

I try to avoid using new features in my blog posts for about least 6 months after a release.

☑ This topic is SOLVED.

Need further help from the community? Please ask a new question.

Discussion stats
  • 6 replies
  • 900 views
  • 1 like
  • 3 in conversation