Selecting Prize winner with spss?

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

Selecting Prize winner with spss?

Jeff
I've collected some survey data that I'll eventually analyze with
spss. First, however, I want to automatically select a winner of a
prize draw from among those who participated in the survey. I have an
spss file of names and chronically ordered id numbers. Since I need
to do this multiple times with various files for various surveys, I
want to do this all via syntax.  Perhaps someone could tell me how to
complete the syntax commands I've started below.

*compute a column of random numbers from 1 to the number of cases *.
compute winner = Rnd(rv.uniform(1,<number of cases in file here>)).

*take only the value from the first row of data in the winner column *.
*and then select the row corresponding to that winner number *.
select if id = <value of winner from the first row>.
exe.

I'm sure that there is a more elegant way, but I think this type of
thing would work. Feel free to suggest a better method.

I'm unsure how to get:
<number of cases in file here>
<value of winner from the first row>

Can someone assist?

Thanks

Jeff

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (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
Reply | Threaded
Open this post in threaded view
|

Re: Selecting Prize winner with spss?

Lemon, John S.
I've done this s number of times for various studies and the route I follow is similar to yours but instead I create the random number with something like this:

compute winner = Rnd(rv.uniform(1, 1000000)).

And

Compute Winid = $CASENUM

I then calculate the mean for winner and find the user with a Winid closest to the mean, if we want a second and third 'winner' then I use the + & - SD :-)

May not be perfect and needs a bit of manual intervention but the local statisticians are happy with the way it works and haven't come up with an alternative solution !!

Best Wishes

John S. Lemon
Student Liaison Officer
IT Services - University of Aberdeen

t:  +44 (0) 1224 273350 | m: +44 (0) 7710 491780 | e:[hidden email] | www.abdn.ac.uk/it/

Use MyIT to log calls with IT Services, and to update and check the status of your calls - https://myit.abdn.ac.uk


-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Jeff
Sent: 06 May 2014 08:18
To: [hidden email]
Subject: Selecting Prize winner with spss?

I've collected some survey data that I'll eventually analyze with spss. First, however, I want to automatically select a winner of a prize draw from among those who participated in the survey. I have an spss file of names and chronically ordered id numbers. Since I need to do this multiple times with various files for various surveys, I want to do this all via syntax.  Perhaps someone could tell me how to complete the syntax commands I've started below.

*compute a column of random numbers from 1 to the number of cases *.
compute winner = Rnd(rv.uniform(1,<number of cases in file here>)).

*take only the value from the first row of data in the winner column *.
*and then select the row corresponding to that winner number *.
select if id = <value of winner from the first row>.
exe.

I'm sure that there is a more elegant way, but I think this type of thing would work. Feel free to suggest a better method.

I'm unsure how to get:
<number of cases in file here>
<value of winner from the first row>

Can someone assist?

Thanks

Jeff

=====================
To manage your subscription to SPSSX-L, send a message to [hidden email] (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
The University of Aberdeen is a charity registered in Scotland, No SC013683.

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (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
Reply | Threaded
Open this post in threaded view
|

Re: Selecting Prize winner with spss?

Jeff
At 05:52 PM 6/05/2014, Lemon, John wrote:

>I've done this s number of times for various studies and the route I
>follow is similar to yours but instead I create the random number
>with something like this:
>
>compute winner = Rnd(rv.uniform(1, 1000000)).
>
>And
>
>Compute Winid = $CASENUM
>
>I then calculate the mean for winner and find the user with a Winid
>closest to the mean, if we want a second and third 'winner' then I
>use the + & - SD :-)
>
>May not be perfect and needs a bit of manual intervention but the
>local statisticians are happy with the way it works and haven't come
>up with an alternative solution !!


Thanks John,

...but since I already have the equivalent of the $casenum column
with my existing ID column, that won't do much more than my version.

I was picturing doing something that would just simply remove all
data rows other the winner(s) - mostly because this was a student
sample and I would have a student standing over me when the winner
was drawn. I wanted to try to do something that would require the
least amount of human intervention possible for this reason.

It's not a big deal, however, so if I don't find a more elegant
solution, I'll likely just do what you suggest - ...just thought it
would be a nice diversion from all of the more serious data analysis
I have to do this week.

So if anyone else has an idea, I wouldn't mind hearing from them.

Best,

Jeff

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (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
Reply | Threaded
Open this post in threaded view
|

Re: Selecting Prize winner with spss?

Andy W
In reply to this post by Jeff
If you currently have your data file open, you can just calculate a random number, sort the file, and then take the first case. Example below:

*************************************.
DATA LIST FREE / Peops.
BEGIN DATA
1
2
3
4
5
6
END DATA.

COMPUTE Rand = RV.UNIFORM(0,1).
SORT CASES BY Rand.
SELECT IF $casenum = 1.
MATCH FILES FILE = * /DROP Rand.
EXECUTE.
*************************************.

Note the random numbers generated by "RND(RV.UNIFORM(1,# of cases))" does not assign equal probabilities to all cases - it sucks for the first person and assigns some probability to "(# of cases) + 1". I would suggest:

TRUNC(RV.UNIFORM(1,# of cases + 1))

You can get the total number of cases from either AGGREGATE or Python, but sorting the data file like this is pretty simple for most circumstances.
Andy W
apwheele@gmail.com
http://andrewpwheeler.wordpress.com/
Reply | Threaded
Open this post in threaded view
|

Re: Selecting Prize winner with spss?

Jeff
...works great Andy - and so easy.

Thanks.

Jeff



At 10:00 PM 6/05/2014, Andy W wrote:
>but
>sorting the data file like this is pretty simple for most circumstances.

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (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