|
Hi,
I require a helping hand in an attempt to try execute something quickly and efficiently. I have a variable which groups respondents into 10 groups. I will create a random uniform number between 0-1. Withing these 10 groups I wish to rank the random variable so in order to select, say for example, the top 3 respondents with the highest random number, then the next top 5 respondent. For group 2 to 10 it will be a different break down, I will not necessary be wanting to select the top 3 then the top 5 again. Any ideas how I could do this? Thanks Jignesh ===================== 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 |
|
Greetings:
UNIFORM will creata a random value, and RANK us used to create a ranking variable: *** sample data-- use your own. DATA LIST FREE /id (F8.0) grp (f8.0). BEGIN DATA 1 1 2 1 3 1 4 1 5 1 6 1 7 1 8 1 4 2 5 2 1 2 6 2 9 2 8 2 5 2 66 2 END DATA . COMPUTE selector = UNIFORM (1). ** change "grp" to match your grouping variable. RANK selector BY grp /RANK INTO select_order. You can use the values of select_order to choose different cases within each goup. --jim -----Original Message----- From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of J Sutar Sent: Monday, March 17, 2008 8:15 AM To: [hidden email] Subject: Computation help Hi, I require a helping hand in an attempt to try execute something quickly and efficiently. I have a variable which groups respondents into 10 groups. I will create a random uniform number between 0-1. Withing these 10 groups I wish to rank the random variable so in order to select, say for example, the top 3 respondents with the highest random number, then the next top 5 respondent. For group 2 to 10 it will be a different break down, I will not necessary be wanting to select the top 3 then the top 5 again. Any ideas how I could do this? Thanks Jignesh ===================== 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 ===================== 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 |
|
In reply to this post by Jignesh Sutar
At 09:14 AM 3/17/2008, J Sutar wrote:
>I have a variable which groups respondents into 10 groups. > >I will create a random uniform number between 0-1. > >Within these 10 groups I wish to rank the random variable so in >order to select, say for example, the top 3 respondents with the >highest randomnumber, then the next top 5 respondent. Let me focus on what you want, not on how to do it. Am I right: you want two non-overlapping random samples from the first group, one with three members and one with five? >For group 2 to 10 it will be a different break down, I will not >necessary be wanting to select the top 3 then the top 5 again. But, presumably, you know how many you do want to select from each group. You're trying to do selection by the 'random sort' method, which does work. In your case, it would look something like (NOT TESTED), COMPUTE RandKey = RV.UNIFORM(0,1). SORT CASES BY GROUP RandKey. * Create a sequence number for cases within a group ... * This can be done using either RANK or a transformation ... * program (*). ... RANK RandKey (A) BY GROUP /RANK INTO RandOrdr. DO IF GROUP EQ 1. . COMPUTE Frst3 = RANGE(RandOrdr,1,3). . COMPUTE Next5 = RANGE(RandOrdr,4,8). ELSE IF GROUP EQ 2. ... END IF. ++++++++++++++++++++++++++++++++++++++++ (*) I've taken this from Date: Tue, 15 Jan 2008 11:15:44 -0800 From: King Douglas <[hidden email]> Subject: Re: drawing samples for hundreds of workers To: [hidden email] There are also other methods for selecting non-overlapping samples, for example variations on the 'K/N' method of sampling. ===================== 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 |
| Free forum by Nabble | Edit this page |
