In IML, following code gives an error:
proc iml;
i=5;
theta={i*3,4};
quit;
This code has no error. But it doesn't run as expected:
proc iml;
i=5;
j=i*3;
theta={j,4};
quit;
What's the reason?
I want to create a column with elements {15,4}.
No, I don't think the syntax is supported like that. Also, I think the second block of code is much prettier, so why not just go with that?
The reason it runs without error is that IML interprets { j , 4 } as a declaration of a character vector. The easiest way to get what you want is to use a concatenation operator:
theta = j // 4;
To expand on Ian's answer, see the article "How to build a vector from expressions."
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.
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.