# Re: selecting lowest scores if missing data or ties

2 messages
Open this post in threaded view
|
Report Content as Inappropriate

## Re: selecting lowest scores if missing data or ties

 Shalom Using restructure it is vary easy to find min max location in a file . Here is a example of  finding the minimum of 5 quiz and deleting the lowest one . If you need more control on the deleting procces you can add  more rolls  like if quiz3 and quiz5 are the lowest select quez5 . input program . loop          ii=1 to 10 . compute       quiz1= trunc(uniform(6)). compute       quiz2= trunc(uniform(6)). compute       quiz3= trunc(uniform(6)). compute       quiz4= trunc(uniform(6)). compute       quiz5= trunc(uniform(6)). end case . end loop . end file . end input program . VARSTOCASES  /MAKE quiz FROM quiz1 quiz2 quiz3 quiz4 quiz5  /INDEX = Index1(5)  /KEEP =  ii  /NULL = KEEP. sort cases    by ii quiz . add files     file=* /by ii/ first=start . if                start eq 1  #seq=0 . compute       #seq=sum(#seq,1). compute       seq=#seq. select if        seq gt 1 . sort cases    by ii index1  . CASESTOVARS  /ID = ii  /INDEX = Index1  /drop=seq start  /GROUPBY = VARIABLE . list . Hillel Vardi Ben Gurion U Israel Dale Glaser wrote: > Hi all....based on Levesques' syntax for selecting maximum score given the case, I was trying same for the case when there are 5 quizzes and isolating (and deleting) the lowest score.......so assuming one has sorted by ID I used the following syntax (appended below)......then I did an incredibly inelegant way of flagging the cases with the lowest scores (which will be deleted in the total summed scoring of the quizzes) by just recreating the initial raw score and then basically mapping the created ranked variable (where a ranked value of 5 is the lowest score) with the raw score and then using some implausible integer (e.g., -1) and code for missing......so though a little cumbersome this works fine.........however, if there is missing data, say a student takes only four of the quizzes, and given they get to drop one quiz, that student will just get a summed score for all four quizzes...the lowest score for that student will not be deleted....so any suggestions as to not >  coding for the lowest score if there is any missing data (akin to using a compute statement such as: 'sum.4' when at least four scores must be answered to compute a score). > >   Also, what if there is the full complement of data for the five quizzes, but there are ties >   for the lowest scores: > >   1 >   1 >   4 >   6 >   7 >   ......when I construct the vector for the ranked variable, as you would guess, it will show up as (for now, the value of 1 being the lowest score): > >   1 >   1 >   3 >   4 >   5 > >   ............what I would like to do is somehow have a unique number and delete only one of the lowest numbers.................any suggestions? > >   thank you very much for your time.....dale > > > >   *********SYNTAX*** > >   ***five quizzes**** >   vector quiz = q1 to q5 . >   loop quizvar = 1 to 5. >   compute quizrate = quiz(quizvar) . >   xsave outfile = 'C:\temp1.sav' >   / keep = id quizvar quizrate. >   end loop. >   execute. > >   ***get the temp file**** > >   rank variables = quizrate (d) by id / ties = low / rank into quizrank . >   numeric RANKq1 RANKq2 RANKq3 RANKq4 rankq5 (f4.1). >   vector quizr = rankq1 to rankq5 . >   compute quizr(quizvar) = quizrank. >   execute. >   aggregate outfile = * >   /presorted / break = id /RANKq1 RANKq2 RANKq3 RANKq4 rankq5 = min(rankq1 to rankq5). >   execute. >   MATCH FILES /FILE = 'C:\Documents\lowscore.sav' >   /FILE = * /BY id . >   execute. > >   **converts lowest score (with value of '5')***and can do this for each variable** > >   ****best to autorecode or rename so don't write over old variables....**** > >   compute q1new=q1. >   compute q2new=q2. >   compute q3new=q3. >   compute q4new=q4. >   compute q5new=q5. >   execute. >   if (rankq1 eq 5) q1new=-1. >   if (rankq2 eq 5) q2new=-1. >   if (rankq3 eq 5) q3new=-1. >   if (rankq4 eq 5) q4new=-1. >   if (rankq5 eq 5) q5new=-1. >   execute. >   missing values q1new to q5new (-1). >   execute. >   freq var=q1new to q5new. >   compute totquiz=sum(q1new to q5new). >   list var=q1new to q5new totquiz. > > > > > > Dale Glaser, Ph.D. > Principal--Glaser Consulting > Lecturer--SDSU/USD/CSUSM/AIU > 4003 Goldfinch St, Suite G > San Diego, CA 92103 > phone: 619-220-0602 > fax: 619-220-0412 > email: [hidden email] > website: www.glaserconsult.com > >