0

In SAS/IML is it possible to change a variable if only a macro with its name is available? Using symget on left side produces mistake:

proc iml;
    variable = 0;
    call symput ('macVar', 'variable');
/*  &macVar = 1;*/
    symget('macVar') = 1;
    print variable;
quit;

ERROR 180-322: Statement is not valid or it is used out of proper order.

The &-sign works, but the code is in a do-loop and symget must be used.

The problem stems from task to write a function that accepts variable number of arguments and processes them in several do-loops. It is connected with the following questions:

SAS IML use of Mattrib with Macro (symget) in a loop

SAS IML pass reference to variable defined in macro

Loop over names in SAS-IML?

In other languages (R, C++, Java, Matlab, etc..) the task is solved with help of abstraction.

Ideas?


SOLVED

Thanks a lot. Useful article.

Community
  • 1
  • 1

1 Answers1

0

Use the VALSET subroutine:

    call valset(symget('macVar'), 1);

You find the article "Read hundreds of data sets into matrices." helpful, since so many of your questions are about similar.

Rick
  • 1,210
  • 6
  • 11