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 (February 2004, week 1)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Wed, 4 Feb 2004 17:24:09 -0500
Reply-To:     Howard Schreier <Howard_Schreier@ITA.DOC.GOV>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         Howard Schreier <Howard_Schreier@ITA.DOC.GOV>
Subject:      Re: 50th Percentile

Don't know offhand. To find out, read the detail in the documentation and/or contrive some experiments.

On Wed, 4 Feb 2004 15:24:03 -0500, Bruce Johnson <bjohnson@SOLUCIENT.COM> wrote:

>Interesting...would Proc Rank give me a better result, in theory? > >________________________________ >Bruce A. Johnson >bjohnson@solucient.com > > >-----Original Message----- >From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of >Howard Schreier >Sent: Wednesday, February 04, 2004 2:16 PM >To: SAS-L@LISTSERV.UGA.EDU >Subject: Re: 50th Percentile > > >Interpolation is one issue, as Venita points out. It's likely with a >continuous variable, or in a small dataset. > >With a discrete variable, or in a large dataset, ties are likely: two or >more values exactly at the median. > >On Wed, 4 Feb 2004 14:35:21 -0500, DePuy, Venita ><depuy001@DCRI.DUKE.EDU> >wrote: > >>Perhaps I'm just misreading this, but aren't you just looking for the >>median?? more specifically, to print the person with the median batting > >>average. >> >>But what if it's not exact? >>Perhaps you want the closest one. >>In that case, would you want to print the person whose batting average >>was closest? (ie if there are an even number of batters, it'd be the >>mean of the two middle people) >>A second revised bit of code follows (after the first) to account for >that >>case. >>HTH >>Venita >> >>data batters; >>input lname $ fname $ avg; >>cards; >>SAMMY SOSA .341 >>MOISES ALOU .249 >>PAUL BAKO .205 >>ALEX GONZALEZ .241 >>ARAMIS RAMIREZ .301 >>COREY PATTERSON .292 >>DAVID KELTON .285 >>; >>run;ods trace off; >>proc univariate; var avg; >> ods output Quantiles=quantiles; >>data _null_; >> set quantiles; >> where Quantile like '50%'; >> call symput ('median',Estimate); >> run; >>%put Median estimate: &median; >> >>proc print data=batters; >> where avg = &median; >>run; >> >>/* Alternate method in case it's not exact */ >>data batters; >>input lname $ fname $ avg; >>cards; >>SAMMY SOSA .341 >>MOISES ALOU .249 >>ALEX GONZALEZ .241 >>ARAMIS RAMIREZ .301 >>COREY PATTERSON .292 >>DAVID KELTON .285 >>; >>run;ods trace off; >>proc univariate; var avg; >> ods output Quantiles=quantiles; >>data _null_; >> set quantiles; >> where Quantile like '50%'; >> call symput ('median',Estimate); >> run; >>%put Median estimate: &median; >> >>data batters; >> set batters; >> diff_avg = abs(avg-&median); >>proc sort; >> by diff_avg; >>data batters; >> set batters; >> if _N_ > 1 then delete; >>proc print data=batters; >>run; >>> ---------- >>> From: Bruce Johnson[SMTP:bjohnson@SOLUCIENT.COM] >>> Reply To: Bruce Johnson >>> Sent: Wednesday, February 04, 2004 2:22 PM >>> To: SAS-L@LISTSERV.UGA.EDU >>> Subject: 50th Percentile >>> >>> I have a project request where I have to find the 50th percentile for > >>> a field, and then print that, along with other information on that >>> particular record. Let's say I have a dataset that is built from >>> this >>> code: >>> >>> data batters; >>> input lname $ fname $ avg; >>> cards; >>> SAMMY SOSA .341 >>> MOISES ALOU .249 >>> PAUL BAKO .205 >>> ALEX GONZALEZ .241 >>> ARAMIS RAMIREZ .301 >>> COREY PATTERSON .292 >>> DAVID KELTON .285 >>> ; >>> run; >>> >>> Proc Univariate, from what I can tell, will not allow me to display >>> the LNAME and FNAME for the AVG that is the 50th percentile. How can > >>> I report the AVG that is the 50th percentile along with the LNAME and > >>> FNAME for that record? >>> >>> Thanks in advance. >>> >>> >This message is a private communication. It may contain information that is confidential and legally protected from disclosure. If you are not an intended recipient, please do not read, copy or use this message or any attachments, and do not disclose them to others. >Please notify the sender of the delivery error by replying to this message, and then delete it and any attachments from your system. >Thank you, >Solucient LLC >(rev eXclaimer 2x)


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