%let N = 150; /* N = sample size */
%let NumSamples = 1; /* number of samples */
proc iml;
call randseed(1);
X = j(&N, 3, 1); /* X[,1] is intercept */
/* 1. Read design matrix for X or assign X randomly.
For this example, x1 ~ U(0,1) and x2 ~ N(0,2) */
X[,2] = randfun(&N, "Bernoulli", 0.5);
X[,3] = randfun(&N, "Uniform",18 , 45);

/* Logistic model with parameters {2, -4, 1} */
beta = {2, -4, 0.1};
eta = X*beta; /* 2. linear model */
mu = logistic(eta); /* 3. transform by inverse logit */

/* create output data set. Output data during each loop iteration. */
varNames = {"Simulation" "y"} || ("x1":"x2"); /* 1st col is Simulation number */
Out = j(&N,1) || X; /* matrix to store simulated data */
create LogisticData from Out[c=varNames];
y = j(&N,1); /* allocate response vector */
do i = 1 to &NumSamples; /* the simulation loop */
Out[,1] = i; /* update value of Simulation */
call randgen(y, "Bernoulli", mu); /* 4. simulate binary response */
Out[,2] = y;
append from Out; /* 5. output this sample */
end; /* end loop */
close LogisticData;
quit;

I am trying to add a unique id on the code you provided and I just made some adjustments to fit what I want to do. This is what I want my data to be like
simulation id y x1 x2
1 1 1 0 18
1 2 0 1 20
1 3 0 0 24
1 4 1 1 28
1 5 0 1 40
2 1 1 1 44
2 2 0 0 25
2 3 1 1 38
2 4 1 1 39
2 5 1 0 41
3 1 1 1 43
3 2 1 0 45
3 3 1 0 43
3 4 0 0 41
3 5 0 1 40

I also want to know how I can do the same in R. Thanks in advance