data set1;
  do iter = 1 to 10000;
  do race = 1 to 1000;
    inside = (ranuni(0) < 1/3);
	output;
  end;
  end;
run;

proc print;
  where iter=1 and race <= 20;
run;

proc sort;
  by iter inside race;
run;

data set1;
  set set1;
  if inside = 1;
  race30 = lag29(race);
  iter30 = lag29(iter);
  if iter = iter30;
  stretch = race - race30;
run;

Proc print obs='obs';
  var race race30 stretch;
  where iter=1 and race <= 150;
run;

proc means data=set1 min noprint;
  var stretch;
  by iter;
  output out=summary(drop=_type_ _freq_) min=min_stretch;
run;

proc print data=summary;
  where iter <= 10;
run;


proc univariate data=summary;
  var min_stretch;
  histogram  / midpoints =(40 to 80 by 1)  cfill = red vaxis = axis1 haxis=axis1;
  histogram  / midpoints =(40 to 80 by 1) normal cfill = red vaxis = axis1;
  axis1 value = (height = 2) label = (height=1.5);
*  axis2 value = (height = 2) label = (height=1.5) major=none;
run;

