Hi Hayley,
You are correct, this function will create reproducible random numbers. I also found another function named PRDUNI which has another parameter that is a seed number. If you change this seed number, then you get different sets of random numbers.
Here is another example using the CAR file that shows different uses of both RDUNIF and PRDUNI:
-*****************************************
-** THIS USES FUNCTION = RDUNIF **
-*****************************************
-* CREATE HOLD FILE FROM CAR
TABLE FILE CAR
PRINT COMPUTE CNTR/I5 = CNTR + 1;
BY CAR
ON TABLE HOLD
END
-* PRINT HOLD FILE WITH 1 RANDOM NUMBER
DEFINE FILE HOLD
RAND_01/D12.8 = RDUNIF(RAND_01);
END
-*
TABLE FILE HOLD
PRINT CNTR CAR RAND_01
END
-* PRINT HOLD FILE WITH 2 RANDOM NUMBERS
DEFINE FILE HOLD
RAND_11/D12.8 = RDUNIF(RAND_11);
RAND_12/D12.8 = RDUNIF(RAND_12);
END
-*
TABLE FILE HOLD
PRINT CNTR CAR RAND_11 RAND_12
END
-* PRINT HOLD FILE WITH 2 RANDOM NUMBERS
DEFINE FILE HOLD
RAND_21/D12.8 = RDUNIF(RAND_21);
RAND_22/D12.8 = RDUNIF(RAND_22);
RAND_23/D12.8 = RDUNIF(RAND_23);
END
-*
TABLE FILE HOLD
PRINT CNTR CAR RAND_21 RAND_22 RAND_23
END
-*****************************************
-** THIS USES FUNCTION = PRDUNI **
-** THE FIRST PARM IS A SEED NUMBER **
-*****************************************
-* PRINT HOLD FILE WITH 1 RANDOM NUMBER
DEFINE FILE HOLD
RAND_01/D12.8 = PRDUNI(40, RAND_01);
END
-*
TABLE FILE HOLD
PRINT CNTR CAR RAND_01
END
-* PRINT HOLD FILE WITH 2 RANDOM NUMBERS
DEFINE FILE HOLD
RAND_11/D12.8 = PRDUNI(50, RAND_11);
RAND_12/D12.8 = PRDUNI(50, RAND_12);
END
-*
TABLE FILE HOLD
PRINT CNTR CAR RAND_11 RAND_12
END
-* PRINT HOLD FILE WITH 2 RANDOM NUMBERS
DEFINE FILE HOLD
RAND_21/D12.8 = PRDUNI(60, RAND_21);
RAND_22/D12.8 = PRDUNI(60, RAND_22);
RAND_23/D12.8 = PRDUNI(60, RAND_23);
END
-*
TABLE FILE HOLD
PRINT CNTR CAR RAND_21 RAND_22 RAND_23
END
I hope this can maybe help others......I think I learned something today.
Thanks Hayley!!
Jim
WebFocus 8.201M, Windows, App Studio