Rick,

Thank you for yet another eminently practical, "make your life easier" blog post. Your blog is one of the first I turn to when I need ideas for SAS.

By the way, with a few quick mods, the macro can be extended such that it can be executed outside a Data step. This (for me) is useful for generating code for test cases. See code below.

Regards,

Jim

%MACRO Rand_Between(Min, Max, Macro=NO);
%IF %QUPCASE(&Macro) = YES %THEN
%DO;
%EVAL(&Min + %SYSFUNC(FLOOR( %SYSEVALF( %EVAL(1 + &Max - &Min) * %SYSFUNC(RAND(Uniform)) ) )))
%END;
%ELSE
%DO;
(&Min + FLOOR((1 + &Max - &Min) * RAND("Uniform")))
%END;
%MEND Rand_Between;