* Rand_treatments.sas;
options pageno=1 linesize=80;
title "Random assignment of Example 2 treatments";
data treat;
	input nitrogen water; 
	* Generate a uniform random variable;
	u = ranuni(0);
	datalines;
 40  125
 40  125
 40  125
 40  125
 40  250
 40  250
 40  250
 40  250
 40  375
 40  375
 40  375
 40  375
 80  125
 80  125
 80  125
 80  125
 80  250
 80  250
 80  250
 80  250
 80  375
 80  375
 80  375
 80  375
120  125
120  125
120  125
120  125
120  250
120  250
120  250
120  250
120  375
120  375
120  375
120  375
;
run;
title2 "Original order of treatments";
proc print data=treat;
run;
* Sort treatments by value of u;
proc sort out=shuffled data=treat;
	by u;
run;
title2 "Randomly shuffled treatments";
proc print data=shuffled;
run;
quit;
