There are other threads out there about randomly selecting rows using other languages, and furthermore my question involves how to define variables from the columns of each randomly selected row.
First I import my data:
proc import OUT = WORK.ROWS
DATAFILE = "C:\rows.xlsx"
DBMS = EXCEL REPLACE; GETNAMES = YES;
run;
proc print;
run;
Which consists of 10 rows, each row containing a pair of two variables (var1, var2) in separate columns. It looks like this:
obs var1 var2
1 0.8828 0.2245
2 0.8833 0.3109
3 0.8699 0.1579
4 0.9035 0.2993
5 0.9641 0.3590
6 0.8846 0.2542
7 0.8752 0.1343
8 0.9309 0.1188
9 0.9018 0.1761
10 0.8832 0.1439
Then, within a DO loop,
DO n = 1 TO 1000; *number of simulations to run;
I would like to randomly draw a single row from the input data file and copy the value of the two variables (var1 and var2) from the row I randomly drew for further use in the same DO loop. In other words, for each iteration of the DO loop, I need to define a new random pair of variables that originated from the same row.
For example, the random values for simulations n = 1 through n = 4 for var1 and var2 could have come from obs (rows) 2, 2, 10, 4:
Simulation #
n = 1
var1 = 0.8846
var2 = 0.2542
n = 2
var1 = 0.8846
var2 = 0.2542
n = 3
var1 = 0.9309
var2 = 0.1188
n = 4
var1 = 0.8832
var2 = 0.1439
Thank you in advance for your help.
DO n=1 to 30
or something reasonable. – Joe