I wanted to take Rick Wicklin's macro (https://blogs.sas.com/content/iml/2015/10/05/random-integers-sas.html) that generates random numbers and convert it into an FCMP function. The FCMP function works as expected when called using %sysfunc(randbetween(1,100));
or via a data step, but from proc sql
it always returns a value of 1.
proc fcmp outlib=work.funcs.funcs;
function randbetween(min,max);
return ( min + floor( ( 1 + max - min ) * rand("uniform") ) );
endsub;
run;
Working example:
data example;
do cnt=1 to 1000;
x = randbetween(1,100);
output;
end;
run;
Broken SQL example:
proc sql noprint;
create table have as
select randbetween(1,100)
from sashelp.class
;
quit;
Is this a bug? Or am I mis-using something?
SAS version is SAS9.4TS1M5. Windows 10x64.
EDIT: When I subsitute the formula directly into the SQL statement it works as expected, so it seems unrelated to the call to rand("uniform")
.
Aucun commentaire:
Enregistrer un commentaire