Calcite | Level 5

## Aleatorization Test

Hello there!

I'm doing a code for aleatorization test on my graduation and I'm stuck in one thing.
I have a column vector and I wanna change the order (randomly) of the number os my vector... how can I do it on IML?

data tensao1;
input tensao @@;
cards;
16.85 16.40 17.21 16.35 16.52
17.04 16.96 17.15 16.59 16.57
;
run;
data tensao2;
input tensao @@;
cards;
16.62 16.75 17.37 17.12 16.98
16.87 17.34 17.02 17.08 17.27
;
run;
proc iml;
reset print;
use tensao1;
use tensao2;
n1=nrow(y1); n2=nrow(y2);
y1_2=y1#y1;
y2_2=y2#y2;
s1=sum(y1_2)/n1-(sum(y1)/n1)**2;
s2=sum(y2_2)/n2-(sum(y2)/n2)**2;
sp=((n1-1)*s1+(n2-1)*s2)/(n1+n2-2);
est_t=((sum(y1)/n1)-(sum(y2)/n2))/(sp*sqrt(1/n1+1/n2));
p_valor=probt(est_t,n1+n2-2);
s1=var(y1);
y=y1//y2;

here I wanna change the order of the numbers and make another matrix y... So i'll have another matrix y1 and y2

y_1=y[1:n1,];
y_2=y[n1+1:n1+n2];

Anyway... sorry about the mess... After I discover it I'll redesign it! =P
SAS Super FREQ

## Re: Aleatorization Test

You need to generate a permutation of the numbers 1:N (N=number of obs) and use the permutation as indices to form a new vector.
There are several ways to do this. The simplest is to generate random uniform numbers and then use the RANK function to assign integers that correspond to the order of the random numbers:

N = 10; /* number of observations in data */
u = j(N, 1); /* allocate Nx1 vector */
call randgen(u, "Uniform"); /* fill u with random uniform */
p = rank(u); /* p is random permutation of 1:N */
print u p;

newY = oldY

; /* new vector = permutation of data */

From The DO Loop