Array, do loop and Marco, part 2

Occasional Contributor
Posts: 14

Array, do loop and Marco, part 2

Dear All,

I only asked half of the questions in the previous one, since I am not good as describing my question, but let me try:

I want to run, say N=1000 simulations, using my macro %tamper(sim=).

And i want to record the result of each simulation in one column, called SurA{}, so at the end of my dataset, I have 1000 column.

Let me call it SurA{1000}.

But I have to get into the marcro %tamper, to change N manually. For example, if N=500, I change to

.....(some where in the macro)

array SurA{500} SurA1-SurA500


How to automate the process?


Super User
Posts: 13,498

Re: Array, do loop and Marco, part 2

Add an N= parameter to the macro like your Sim parameter if the value is different than SIM, or use &sim instead of &N below if always the value of Sim.

Array SurA{&N} SurA1 - SurA&N;

Super User
Posts: 23,662

Re: Array, do loop and Marco, part 2

You may want to look up Rick Wicklins blog post on loopy macros. I haven't seen a full example of what you're doing, but my GUESS is that you'd be better of using BY GROUP processing within your simulation.  If its less than 10000 iterations, I usually find it's faster.  I think there's also a limit to how large an array can get.

Here's some resources you may find useful:

Statistical Computing Seminar: Arrays in SAS

Ask a Question
Discussion stats
  • 2 replies
  • 3 in conversation