> 1. Do you then think it necessary to perform the repeated resampling as per examples, or can one just use each combination a single time? (This may be better asked at stackexchange)
Statistical tests that are computationally expensive come in two forms. The exact test will examine the exact sampling distribution of a statistic by using all possible combinations/permutations and obtain an exact p-value for the test. The Monte Carlo estimate of that test will consider a large number of random combinations/permutations to obtain an approximate sampling distribution and an exact p-value. For an example and discussion, see Monte Carlo simulation for contingency tables in SAS - The DO Loop
I can't advise you on how to proceed because I do not know what test you are running, or what the distribution of the statistic is. Reference?
2. Is there some way to call EXPANDGRID with a varying number of arguments?
Yes. Sure, anytime you want to "write SAS code that writes some SAS code," there are two options: CALL EXECUTE or SAS macro. Ian suggested CALL EXECUTE. Here is an example that uses the macro language:
data two;
set one nobs=n; /* get sample size */
d = y1 - y2;
call symputx("nobs", n); /* put it in a macro variable */
run;
/* create a comma separated list that repeats an argument n times */
%macro ListVal(v, nTimes);
%do i = 1 %to %eval(&nTimes-1);
&v,
%end;
&v
%mend;
proc iml;
s = "%ListVal({-1 1}, &nobs)"; /* view the result */
print s;
/* use it in ExpandGrid */
v = expandgrid( %ListVal({-1 1}, &nobs) );
print v;
> 3. Do you think there is any value here to trading memory efficiency for computational inefficiency?
An efficient IML program will vectorize operations (which means, turn them into linear algebra operations) and will avoid lots of loops over elements of vectors. So, in general, I would avoid the programming method that you are proposing. If memory is an issue, you can sometimes refactor a memory-intensive operation to use block computations. But I do not suggest that you start there. First, define your problem, explain the method you are trying to use, and write a program that works efficiently on small data.
... View more