random value assignment in SPSS

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

random value assignment in SPSS

Burkhard Gniewosz
Hi

I want to pair students from my SPSS data set randomly. Variable 1
contains the student ID (numeric, but random, not consecutively numbered).
To each student ID (Variable 1) another student ID (variable2) should be
randomly assigned.
 Does anybody know the syntax code for randomly picking a specific value
form variable 1 and write it into variable 2? Defining the range of
Variable1 and randomly picking a value from this range does not work,
because the are gaps in the progression of the student ID, like
1,2,7,8,23,35 ....

I would really appreciate your help
Thanks

Burkhard
Reply | Threaded
Open this post in threaded view
|

Re: random value assignment in SPSS

Maguin, Eugene
Burkhard,

You could save just variable 1 to a new file. Open that file and do one of
two things. Either, sort the variable in either ascending or descending
order, rename that variable, and save. (This works only because your
variable 1 is itself a random number.) Or, draw a number from a uniform
distribution and then sort the file on that variable, rename the original
variable (variable 1), and save. Next, do a match files with no By variable.
The idea is that the program will add the record 1 value to record 1 of the
other file, and so on. If you have trouble with the match files operation,
you need to add the case number ($casenum) to each file and then match on
case number.

Repost if you need specific syntax.

Gene Maguin