Using the APPEND statement, output data can be created within Proc IML. Using Proc Append within a macro do loop, output can be concatenated from multiple, separate Proc IML calls within that macro.
My question concerns concatenating or updating output data within a do loop from a single Proc IML call. The APPEND statement only retains the most recent value from the loops. I would like to track the successive values within each iteration of that loop. So, if the loop iterates 100 times, then there would be 100 values appended to a single output data set.
Is this possible in Proc IML?
Yes, you need to put the APPEND statement in the loop itself, so that the APPEND statement executes 100 times.
Yes, you need to put the APPEND statement in the loop itself, so that the APPEND statement executes 100 times.
Your comment helped jog me into a solution. By placing the "create" statement above the initiation of the do loop, placing the "append" statement withing the loop and the "close" statement after the end of the loop, I got the desired results.
Thanks!
I'll add that you can use this same technique to write data sets that are larger than can fit into RAM, or to write the results of multivariate computations without needing to remember the results while inside the loop.
For using this technique to write large data, see "Writing data in chunks"
To see it in an application of simulating logistic response variable, see "Simulate many samples from a logistic regression model"
Search for "Append" on this pages and notice that the append is inside a DO loop, but the CREATE and CLOSE are not.
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
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.