Turn on suggestions

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

Showing results for

Options

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

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

Posted 07-28-2010 12:41 PM
(1217 views)

SAS uses the "*" for comments.

IML uses the "*" for matrix multiplication.

How can I use matrix multiplication in SAS/IML? It makes the text after the "*" purple indicating a comment???

-- Note: I am using Proc IML in a macro. Shouldn't matter though as the "*" is for comments in macros, just as in base SAS.

Please also email me directly your answers!! (steveseoul@yahoo.com)

Thanks,

Steve

IML uses the "*" for matrix multiplication.

How can I use matrix multiplication in SAS/IML? It makes the text after the "*" purple indicating a comment???

-- Note: I am using Proc IML in a macro. Shouldn't matter though as the "*" is for comments in macros, just as in base SAS.

Please also email me directly your answers!! (steveseoul@yahoo.com)

Thanks,

Steve

2 REPLIES 2

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

Steve,

The "*" signals a comment only if it is the first character of a new source statement. In the context of a binary operation it is treated as a matrix multiplication operator :

proc iml;

a = 1;

b = 1;

* this is a comment;

y = a * b; /* this is a matrix multiply operation */

print y;

The "*" signals a comment only if it is the first character of a new source statement. In the context of a binary operation it is treated as a matrix multiplication operator :

proc iml;

a = 1;

b = 1;

* this is a comment;

y = a * b; /* this is a matrix multiply operation */

print y;

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

You can use the "alternative commment" (asterisk ... semicolon) at the end of lines, like this:

proc iml;

A = {1 2, 3 4}; * matrix assignment statment;

x = {5, 6}; * vector assignment statment;

y = A*x; * matrix multiplication;

print y;

As Hutch points out, they are also valid on separate lines. The matrix operator is in the middle of a statement, so the IML parser can distinguish that it is not a comment.

It sounds like the color-coding shown in your editor is getting confused by the alternate comment syntax. Just ignore the color-coding, or use traditional slash-star comments (/* ... */).

proc iml;

A = {1 2, 3 4}; * matrix assignment statment;

x = {5, 6}; * vector assignment statment;

y = A*x; * matrix multiplication;

print y;

As Hutch points out, they are also valid on separate lines. The matrix operator is in the middle of a statement, so the IML parser can distinguish that it is not a comment.

It sounds like the color-coding shown in your editor is getting confused by the alternate comment syntax. Just ignore the color-coding, or use traditional slash-star comments (/* ... */).

**SAS Innovate 2025** is scheduled for May 6-9 in Orlando, FL. Sign up to be **first to learn** about the agenda and registration!

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.