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 (April 2009, week 3)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:   Mon, 20 Apr 2009 11:09:17 -0500
Reply-To:   Joe Matise <snoopy369@GMAIL.COM>
Sender:   "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:   Joe Matise <snoopy369@GMAIL.COM>
Subject:   Re: remove the lowest 2 scores and avg on the rest
Comments:   To: Chang Chung <chang_y_chung@hotmail.com>
In-Reply-To:   <200904201559.n3KFXNM0024466@malibu.cc.uga.edu>
Content-Type:   text/plain; charset=ISO-8859-1

Of course missing and zero are different... but what I meant was that if you failed to take a test, it was treated as 'zero', not 'missing'. :)

I'll guess 'the length parameter in POKELONG' (40, not 80) as the location of your error, by the way. :)

-Joe

On Mon, Apr 20, 2009 at 10:59 AM, Chang Chung <chang_y_chung@hotmail.com>wrote:

> On Mon, 20 Apr 2009 10:40:48 -0500, Joe Matise <snoopy369@GMAIL.COM> > wrote: > > >Maybe things have changed since I went to school, but a missing value for > a > >test score was a 'zero' back in the day... :) I'd either transform the > >missings to zero (if you have actual missing in the data) or do sum(of > >q3-q5)/3 ... > > > hi, Joe, > > in terms of data processing, a missing and a zero are totally different > things. Maybe teachers back then didn't have the sophisticated software > system like sas to make such a fine distinction. :-) > > by the way, I hard-coded "5" all over the place and made one mistake(guess > where?). that's not good. here is a parameterized and corrected one. :-) > > cheers, > chang > > /* test data. dot means the quiz missed. */ > data one; > input name $ q1-q5; > cards; > Alex 1 2 3 4 5 > Betty 2 2 . 4 4 > Clare 5 4 . . . > David 5 4 3 2 1 > ; > run; > > /* calculate mean quiz scores based on the > number of quizes taken, after dropping > two lowest scores. missing is considered > as the lowest score. */ > %let maxq = 5; /* change this to 12 if you have q1-q12 */ > %let mlen = %eval(&maxq. * 8); > data two; > set one; > /* make a copy */ > array q[1:&maxq.] 8 q1-q&maxq.; > array t[1:&maxq.] 8 _temporary_; > call poke(put(peekc(addr(q[1]),&mlen.),$&mlen..),addr(t[1]),&mlen.); > /* remove lowest two */ > call sortn(of t[*]); > call missing(t[1], t[2]); > /* calc n and mean */ > n = n(of t[*]); > mean = mean(of t[*]); > run; > > /* report */ > proc print data=two noobs; > run; > /* on lst > name q1 q2 q3 q4 q5 n mean > > Alex 1 2 3 4 5 3 4.00000 > Betty 2 2 . 4 4 3 3.33333 > Clare 5 4 . . . 2 4.50000 > David 5 4 3 2 1 3 4.00000 > */ >


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