I found a Stata command called permute (imagine that) that I did not
know existed. The help gives this example, which I think is similar to
what I want to do:
program define panova
version 8.1
args y treat subject
anova `y' `treat' `subject'
test `treat'
end
. permute treat "panova y treat subject" F=r(F), reps(1000)
strata(subject)