RANDOM vs REPEATED in SAS

Consider using PROC HPMIXED which uses sparse matrix manipulations (observation order matters):

options fullstimer;

data testsmall;
  do i = 1 to 10;
    yi = normal(0);
    do j = 1 to 5;
	  yj = normal(0);
	  do k = 1 to 30;
	   y = yi + yj + normal(0);
	   output;
	   end;
	 end;
   end;

 proc mixed noclprint data=testsmall;
   class i j;
   model y = ;
   random i j(i);
   title 'Small, random';
   run;

proc mixed noclprint data=testsmall;
  class i j;
  model y = ;
  random j(i) /subject=i type=cs;
  title 'Small, random J(I) with subject I';
  run;

proc mixed noclprint data=testsmall;
  class i j;
  model y = ;
  random j /subject=i type=cs;
  title 'Small, random J with subject I';
  run;

proc mixed noclprint data=testsmall;
  class j;
  model y = ;
  random j /subject=i type=cs;
  title 'Small, random J with subject I continuous';
  run;


proc mixed noclprint data=testsmall;
   class i j;
   model y = ;
   random i;
   repeated /subject=j(i) type=cs;
   title 'Small, random I and repeated J(I)';
   run;

proc mixed noclprint data=testsmall;
   class i j;
   model y = ;
   random i;
   repeated /subject=j type=cs;
   title 'Small, random I and repeated J';
   title2 'Not same model - j is crossed, not nested';
   run;


data testlarge;
  do i = 1 to 100;
    yi = normal(0);
    do j = 1 to 50;
	  yj = normal(0);
	  do k = 1 to 3;
	   y = yi + yj + normal(0);
	   output;
	   end;
	 end;
   end;

/* not run - very slow 
proc mixed noclprint data=testlarge;
   class i j;
   model y = ;
   random i j(i);
   title 'Large, random';
   run;
 */

proc mixed noclprint data=testlarge;
  class i j;
  model y = ;
  random j(i) /subject=i type=cs;
  title 'Large, random with subject';
  run;


proc mixed noclprint data=testlarge;
  class i j;
  model y = ;
  random j /subject=i type=cs;
  title 'Large, random J with subject I';
  run;
  
proc mixed noclprint data=testlarge;
  class j;
  model y = ;
  random j /subject=i type=cs;
  title 'Large, random J with subject I continous';
  run;
  
  
 proc mixed noclprint data=testlarge;
   class i j;
   model y = ;
   random i ;
   repeated /subject=j(i) type=cs;
   title 'Large, random and repeated J(I)';
   run;

proc hpmixed noclprint data=testlarge;
   class i j;
   model y = ;
   random i j(i);
   title 'Large, random';
   run;

proc hpmixed noclprint data=testlarge;
   class i j;
   model y = ;
   random j / subject = i type=cs;
   title 'Large, random with subject';
   run;

proc export data=testlarge outfile='testlarge.csv';
run;