|
Debbie Hahs-Vaughn wrote:
>
> I have used COMPUTE ID=$CASENUM to generate consecutive identification
> numbers. However how can I generate identification numbers that are not
> consecutive but just purely random? I am trying to avoid having numbers
> that are only one digit difference in the ID so that there is less room
> for
> error in what we are trying to do. Thanks!
>
>
Instead of $casenum, use one of the random variable functions, such as
RV.UNIFORM. From the Help:
RV.UNIFORM. RV.UNIFORM(min, max). Numeric. Returns a random value from a
uniform distribution with specified minimum and maximum. See also the
UNIFORM function.
If you want to obtain the same IDs every time you run the syntax, set the
value of the seed first (via the SET command). Here's the description of
the seed from the Help:
"Initialization value for MC random number generator. The value must be a
positive integer that is less than 2,000,000,000 or the keyword RANDOM,
which randomly sets the initialization value. The default is 2,000,000."
And finally, assuming you have one row per ID, you'll want to follow up
with a check for duplicate IDs. It's not very likely, but could happen.
-----
--
Bruce Weaver
bweaver@lakeheadu.ca
http://sites.google.com/a/lakeheadu.ca/bweaver/
"When all else fails, RTFM."
NOTE: My Hotmail account is not monitored regularly.
To send me an e-mail, please use the address shown above.
--
View this message in context: http://spssx-discussion.1045642.n5.nabble.com/generating-random-not-consecutive-identification-numbers-tp2855693p2855817.html
Sent from the SPSSX Discussion mailing list archive at Nabble.com.
=====================
To manage your subscription to SPSSX-L, send a message to
LISTSERV@LISTSERV.UGA.EDU (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD
|