You need calling @Rick_SAS
Here is an example if you have SAS/IML .
data have;
input ID col_A col_B col_C;
cards;
101 2 80 20
102 4 40 22
103 5 20 25
104 3 90 20
105 8 10 22
101 2 80 20
102 4 40 22
103 5 20 25
104 3 90 20
105 8 10 22
101 2 80 20
102 4 40 22
103 5 20 25
104 3 90 20
105 8 10 22
104 3 90 20
105 8 10 22
101 2 80 20
102 4 40 22
103 5 20 25
104 3 90 20
105 8 10 22
102 4 40 22
103 5 20 25
104 3 90 20
105 8 10 22
;
%let n_simulation=10000;
proc iml;
use have nobs nobs;
read all var _all_ ;
close;
want=j(&n_simulation.,1,.);
call randseed(12345678);
do i=1 to &n_simulation.;
call randgen(rand_no,'uniform');
N=min(nobs,int(sample(col_C,1)*rand_no)+1);
want[i]=sample(col_B,N,'wor')[:];
end;
create want var{want};
append;
close;
quit;
Edited: Adding MIN() function.
... View more