BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
xtc283x
Quartz | Level 8

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?

1 ACCEPTED SOLUTION

Accepted Solutions
PaigeMiller
Diamond | Level 26

Yes, you need to put the APPEND statement in the loop itself, so that the APPEND statement executes 100 times.

--
Paige Miller

View solution in original post

3 REPLIES 3
PaigeMiller
Diamond | Level 26

Yes, you need to put the APPEND statement in the loop itself, so that the APPEND statement executes 100 times.

--
Paige Miller
xtc283x
Quartz | Level 8

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!

Rick_SAS
SAS Super FREQ

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.

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

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.

From The DO Loop
Want more? Visit our blog for more articles like these.
Discussion stats
  • 3 replies
  • 1458 views
  • 3 likes
  • 3 in conversation