Hi guys ! I am new to sas and need some help in simulation. I have a dataset that looks like this (name : simul_input) ID col_A col_B col_C 101 2 80 20 102 4 40 22 103 5 20 25 104 3 90 20 105 8 10 22 . . . . 100 data points step 1) The simulation takes col_C and and a random number (rand_no) and computes another number N (N = col_C*rand_no) step 2) Now, for each step of my simulation i need to select N elements at random (without replacement) from col_B and compute their sum, and then store this sum in a separate dataset (lets say : simul_output). so if I run this simulation say 10,000 times, my 'simul_output' should contain 10,000 entries. (in general : If I am running the simulation for N number of times, step1 and step2 will take place N times. and 'simul_data' will contain N entries) I have a pretty standard code in sas which lets me select "k" random entries from a variable with "n" observation here is the code : data want(keep = id x);
retain k 5;
set have nobs = n;
if rand ("uniform") < k/n then do;
output;
k = k-1;
end;
n = n-1;
run; (code obtained from : https://sasnrd.com/sas-random-sampling-without-replacement/)
... View more