I have written a SAS/IML module to print a matrix using an optional parameter list. The module is quite simple:
proc iml ;
a={1 2 3, 4 5 6} ;
start print_mat( matrix= ) ;
print 'isSkipped=' (isSkipped( matrix )) ;
print 'isEmpty =' (isEmpty ( matrix )) ;
print 'matrix=' matrix ;
finish ;
run print_mat( a ) ;
run print_mat( matrix=a ) ;
quit ;
and it works for the first invocation of print_mat without the optional parameter syntax, but stumbles for the second invocation where the optional parameter list syntax is used. I do not understand why I get the following error message:
If you do not have other questions, please close this thread.
Unlike a SAS macro, which supports both positional and keyword syntax, a SAS/IML function only supports positional parameters. You can't call the function by using
run print_mat( matrix=a );
only by using
run print_matrix(a);
When you use that syntax, SAS tries to evaluate the expression "matrix=a", which is a boolean matrix, so that it can pass the appropriate matrix to the function. However, there is no variable named 'matrix', so the expression "matrix=a" results in an error. It's the same error you will get if you run
y = (matrix=a);
Thank you for an informative reply. I misunderstood the syntax in the example contained in the webpage that I cited and thought that I could use the optionality of a parameter the same way that I can use a SAS/Macro keyword parameter.
If you do not have other questions, please close this thread.
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.
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.