LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous messageNext messagePrevious in topicNext in topicPrevious by same authorNext by same authorPrevious page (September 2010)Back to main SPSSX-L pageJoin or leave SPSSX-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:   Mon, 27 Sep 2010 12:32:46 -0700
Reply-To:   Bruce Weaver <>
Sender:   "SPSSX(r) Discussion" <SPSSX-L@LISTSERV.UGA.EDU>
From:   Bruce Weaver <>
Subject:   Re: generating random (not consecutive) identification numbers
In-Reply-To:   <>
Content-Type:   text/plain; charset=us-ascii

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

"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: Sent from the SPSSX Discussion mailing list archive at

===================== 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

Back to: Top of message | Previous page | Main SPSSX-L page