# Generate Random Numbers Using SPSS

1. Invoke SPSS
2. Under the Data menu select Insert Variable. Call it v1.
3. Select Insert Case from the Data menu. A missing value symbol .'' should appear in the first cell under variable v1. Highlight that cell, copy, and paste it in 29 highlighted cells under v1 so that 30 empty cells will exist under v1.
4. Under the Transform menu, select Compute. In the resulting screen, put v1 in the box labeled Target Variable. In the list of functions, scroll down and select RV.UNIFORM. (Press the arrow boxes in the window with your cursor). We will generate 30 random numbers from a by means of this SPSS function.
5. After you clicked OK, acknowledge the change existing variable warning, so that 30 numbers will appear under v1. You will notice that they are decimal numbers. The uniform distribution which SPSS provides is the one for a continuous random variable. Let us generate random numbers for a discrete random variable instead as if we are tossing a fair die.
6. Go back to Compute in the Transform menu. Put your cursor in the box where RV.UNIFORM is shown and type in the box the following command: RND(RV.UNIFORM(2,8)). The function RND will round the uniform random numbers to produce integers. However, we need to compensate for round-off error on the end points; so type again so that you will see:
RND(RV.UNIFORM(2-.4999,8+ .4999)). Click OK, acknowledge that you will overwrite the values for v1 to produce 30 random numbers from a U(2,8) discrete distribution.
7. Generate a second column of random numbers like before but call the Target Variable v2.
8. Go back to Compute in the Transform menu. Put your cursor in the box where RV.UNIFORM is shown and type in the box the following command: RV.NORMAL(5,2). This command will generate 30 random numbers from a distribution.