Hello guys ! I am new to SAS, please help me figure this out.
I have a dataset that looks like this (name : simulation_data) :-
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
Now, On this data I have to do a simulation kind of thing where for each entry in 'col_c' (lets say first entry : 20) I have to select 20 random numbers from col_B and take the sum of those 20 selected enties.
So for all the 100 observations in 'col_C', col_C amount of entries have to be selected from 'col_B', sum of all those selected entries have to be taken and the number obtained in each interation has to be appended in a seperate dataset (or in this dataset itself).
I have tried the first step of the process (i.e. to take col_C number of elements from the simulation_data at random) :
data col_c_data;
set simulation_data nobs = n;
retain k col_C;
if rand ("uniform") < k/n then do;
output;
k = k-1;
end;
n = n-1;
run;
This is a standard code to take "k" random entries from a variable with "n" observation
(code obtained from : https://sasnrd.com/sas-random-sampling-without-replacement/)
but col_c_data produced is an empty one and LOG says that "Missing values were generated as a result of performing an operation on missing values".
apart from the method I am familiar with "proc survey select"