|
The following code was suggested in a posting earlier this month:
>set seed =300.
>compute random =uniform(333).
>sort cases by n.hosp random.
I just looked at it and said, that CAN'T work: since the seed is set back
to 300 for each case, all the random values will be the same.
But it does work. Below is SPSS draft output, with SET SEED *within* the
transformation program, just to make sure, and the random value is
different for each case.
What's up? I thought that SET was an executable statement -- that it could
be governed by DO IF, that you could reset the same value several times in
a transformation program. Is SET SEED somehow special? If so, what are the
rules for how it works?
NEW FILE.
INPUT PROGRAM.
NUMERIC REC_NUM (F4).
LOOP REC_NUM = 1 TO 10.
. END CASE.
END LOOP.
END FILE.
END INPUT PROGRAM.
SET SEED=100.
NUMERIC RAND_VAL (F6.2).
COMPUTE RAND_VAL = UNIFORM(1000).
SET SEED=100.
LIST.
List
REC_NUM RAND_VAL
1 496.26
2 8.87
3 982.43
4 939.86
5 160.26
6 927.73
7 297.92
8 169.17
9 979.40
10 656.66
Number of cases read: 10 Number of cases listed: 10
|