Statistical programming, matrix languages, and more

Appending or updating information within a Proc IML do loop

Accepted Solution Solved
Reply
Contributor
Posts: 59
Accepted Solution

Appending or updating information within a Proc IML do loop

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?


Accepted Solutions
Solution
‎10-22-2015 11:08 AM
Trusted Advisor
Posts: 1,505

Re: Appending or updating information within a Proc IML do loop

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

View solution in original post


All Replies
Solution
‎10-22-2015 11:08 AM
Trusted Advisor
Posts: 1,505

Re: Appending or updating information within a Proc IML do loop

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

Contributor
Posts: 59

Re: Appending or updating information within a Proc IML do loop

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!

SAS Super FREQ
Posts: 3,420

Re: Appending or updating information within a Proc IML do loop

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.

☑ This topic is SOLVED.

Need further help from the community? Please ask a new question.

Discussion stats
  • 3 replies
  • 484 views
  • 3 likes
  • 3 in conversation