Calculating Median

Joe Boyle joeboyle_adt@hotmail.com
Tue, 3 Aug 2004 22:56:17 +0100


This is a multi-part message in MIME format.

------=_NextPart_000_0000_01C479AD.15E30880
Content-Type: text/plain;
	charset="us-ascii"
Content-Transfer-Encoding: 7bit

I can probably do it in two, but I'd have to use syntax like that below, it
uses the system to store a value between record complex reads, you may have
to set a variable named d2var to 0 before running the quiz.

 

Acc * sf1 link .etc. 

 

Sort on median-item

 

Define d1 char*15 = getsystemval(d2var) if record sf1 exists

 

Define d0 = tot-recs if nconvert (d1) = 0

 

Define d-rec-num int * 8 = floor (tot-recs/2 ) if 0.5 lt mod ( d0 ,2 )

 

Define d3 int = nconvert (d1) + 1 if record sf1 exists

 

Define d2 char*15 = setsystemval(ascii (dvar)) if record sf1 exists

 

Define d-median = median-item of sf1 if d3 = d-rec-num 

 

Report d-median

 

The first pass gets the total count, from which the record position in the
sorted file can be determined, the code above selects the value matching the
record id.

 

First pass,

 

Access f1 .

 

Sort on median-item descending

 

Define tot-recs = 1

 

Set sub name sf1 keep

 

Rep summ median-item  tot-recs subtotal

 

 

  _____  

From: powerh-l-admin@lists.sowder.com
[mailto:powerh-l-admin@lists.sowder.com] On Behalf Of Deskin, Bob
Sent: 29 July 2004 12:26
To: PowerHouse List
Subject: RE: Calculating Median

 

And then there's the QUIZ solution. Let's say you want the median for item
x. If the number of records is odd you want the value of x for record
(n+1)/2. If the number of records is even, you want the average (sum divided
by count) of the values of x for the two records n/2 and (n/2)+1.

 

I can do this report in 4 passes (remember Name that Tune). Anyone for 3?

 

Disclaimer: I have not tested this other than in my head, and we all know
what can happen when we only test in our heads :-)

 

access file

sort on x

define x-count integer = 1

report summary x x-count subtotal

set subfile name xsub

go  ; this gives the values in sequence with a sequence number

 

access *xsub

define n = 1

define x-1 = 1

sorted on x-1

report summary n subtotal

set subfile name xtotal at x-1  ; this is the same as AT FINAL which QUIZ
doesn't have

go  ; this gives the total count n

 

access xtotal

define x-med1 integer = (n + 1)/2 if 1 = mod(n,2) else n/2

define x-med2 integer = (n + 1)/2 if 1 = mod(n,2) else (n/2) + 1 

define x-1 = 1

sorted on x-1

report summary x-med1 x-med2

set subfile name xmedian at x-1

go  ; this gives the record numbers of the one or two records you want

 

set nosubfile

access *xsub link to record 0 of xmedian  ; record 1 on OpenVMS and OS/400

select if x-count = x-med1 or x-count = x-med2

; if x-med1 = x-med2 only one record will be selected

; if x-med1 <> x-med2 two records will be selected

report x average x-med1 x-med2

go  ; this gives the median

 

Bob Deskin              
Senior Product Manager, Application Development Tools 
Cognos Inc. 3755 Riverside Drive, Ottawa ON K1G 4K9 CANADA 
bob.deskin@cognos.com (613) 738-1338 ext 7268 

-----Original Message-----
From: powerh-l-admin@lists.sowder.com
[mailto:powerh-l-admin@lists.sowder.com]On Behalf Of Robert Edis
Sent: July 28, 2004 7:11 PM
To: PowerHouse List
Subject: RE: Calculating Median

No, no, no ... I'm innocent I tell you!

 

Ordinarily I would agree but in this particular case I suggest Quick because
of simplicity.  Exception-to-the-rule and all that.

 

Of couse I could of suggested using a 3GL tool - an external function if you
like. :)

 

Blue

David Morrison - Corporate <dmorrison@mcbrideelectric.com> wrote:

Blue,

 

Ah, you're just trying to start trouble on the list-serve aren't you!
Didn't we just have a discussion about why not to use QUICK when QTP or QUIZ
will do (and I was on the side of the QUICK solution)?

 

Cordially,

 

David Morrison

McBride Electric

 

-----Original Message-----
From: powerh-l-admin@lists.sowder.com
[mailto:powerh-l-admin@lists.sowder.com]On Behalf Of Robert Edis
Sent: Wednesday, July 28, 2004 1:48 PM
To: PowerHouse List
Subject: RE: Calculating Median

 

Why do it in Quick?  Then you have looping, designer files, and temporary
variables available for the logic.  No subfile is required and all
processing can be done in designer procedures.  

 

Added bonus is that user can run screen and get median value any time they
choose without MIS getting involved.

 

Blue

David Morrison - Corporate <dmorrison@mcbrideelectric.com> wrote:

Blair,

How about something like this:

Use a QTP program that does the following:

1. First request: Sort the data on the value that you're looking to get the
median for. Output records to a sub-file at that value, outputting the value
and COUNT RESET. Put COUNT NORESET into a global temporary item. 

2. Second request: Read the sub-file created in the previous step (they're
already sorted). Accumulate the total of the counted field in each record.
Compare that to the global tempor! ary; when it reaches 1/2 of that total,
you have the median value. 


David Morrison
McBride Electric

-----Original Message-----
From: powerh-l-admin@lists.sowder.com
[mailto:powerh-l-admin@lists.sowder.com] On Behalf Of Blair Combs
Sent: Wednesday, July 28, 2004 12:23 PM
To: Powerhouse Listserv
Subject: Calculating Median

Does anyone ha! ve an idea on how to calculate the Median for a list of 
numbers using Quiz?

Blair Combs
Idaho State University

= = = = = = = = = = = = = = = = = = = = = = = = = = = =
Mailing list: powerh-l@lists.sowder.com
Subscribe: "subscribe" in message body to powerh-l-request@lists.sowder.com
Unsubscribe: "unsubscribe " in message body to
powerh-l-request@lists.sowder.com
http://lists.sowder.com/mailman/listinfo/powerh-l
This list is closed, thus to post to the list you must be a subscriber.



= = = = = = = = = = = = = = = = = = = = = = = = = = = =
Mailing list: powerh-l@lists.sowder.com
Subscribe: "subscribe" in message body to powerh-l-request@lists.sowder.com
Unsubscribe: "unsubscribe " in message body to
powerh-l-request@lists.sowder.com
http://lists.sowder.com/mailman/listinfo/powerh-l
This list is closed, thus to post to the list you must be a subscriber.

 

       This message may contain privileged and/or confidential information.
If you have received this e-mail in error or are not the intended recipient,
you may not use, copy, disseminate or distribute it; do not open any
attachments, delete it immediately from your system and notify the sender
promptly by e-mail that you have done so.  Thank you. 


------=_NextPart_000_0000_01C479AD.15E30880
Content-Type: text/html;
	charset="us-ascii"
Content-Transfer-Encoding: quoted-printable

<html xmlns:v=3D"urn:schemas-microsoft-com:vml" =
xmlns:o=3D"urn:schemas-microsoft-com:office:office" =
xmlns:w=3D"urn:schemas-microsoft-com:office:word" =
xmlns:st1=3D"urn:schemas-microsoft-com:office:smarttags" =
xmlns=3D"http://www.w3.org/TR/REC-html40"
xmlns:ns0=3D"http://www.exclaimer.co.uk">

<head>
<meta http-equiv=3DContent-Type content=3D"text/html; =
charset=3Dus-ascii">
<meta name=3DGenerator content=3D"Microsoft Word 11 (filtered medium)">
<!--[if !mso]>
<style>
v\:* {behavior:url(#default#VML);}
o\:* {behavior:url(#default#VML);}
w\:* {behavior:url(#default#VML);}
shape {behavior:url(#default#VML);}
</style>
<![endif]--><o:SmartTagType
 namespaceuri=3D"urn:schemas-microsoft-com:office:smarttags" =
name=3D"PlaceType"/>
<o:SmartTagType =
namespaceuri=3D"urn:schemas-microsoft-com:office:smarttags"
 name=3D"PlaceName"/>
<o:SmartTagType =
namespaceuri=3D"urn:schemas-microsoft-com:office:smarttags"
 name=3D"place"/>
<o:SmartTagType =
namespaceuri=3D"urn:schemas-microsoft-com:office:smarttags"
 name=3D"PersonName"/>
<!--[if !mso]>
<style>
st1\:*{behavior:url(#default#ieooui) }
</style>
<![endif]-->
<style>
<!--
 /* Font Definitions */
 @font-face
	{font-family:Tahoma;
	panose-1:2 11 6 4 3 5 4 4 2 4;}
 /* Style Definitions */
 p.MsoNormal, li.MsoNormal, div.MsoNormal
	{margin:0cm;
	margin-bottom:.0001pt;
	font-size:12.0pt;
	font-family:"Times New Roman";}
a:link, span.MsoHyperlink
	{color:blue;
	text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
	{color:purple;
	text-decoration:underline;}
p.MsoAutoSig, li.MsoAutoSig, div.MsoAutoSig
	{margin:0cm;
	margin-bottom:.0001pt;
	font-size:12.0pt;
	font-family:"Times New Roman";}
p
	{mso-margin-top-alt:auto;
	margin-right:0cm;
	mso-margin-bottom-alt:auto;
	margin-left:0cm;
	font-size:12.0pt;
	font-family:"Times New Roman";}
span.EmailStyle17
	{mso-style-type:personal;
	font-family:Arial;
	color:navy;}
span.EmailStyle20
	{mso-style-type:personal-reply;
	font-family:Arial;
	color:navy;}
@page Section1
	{size:612.0pt 792.0pt;
	margin:72.0pt 90.0pt 72.0pt 90.0pt;}
div.Section1
	{page:Section1;}
-->
</style>

</head>

<body lang=3DEN-US link=3Dblue vlink=3Dpurple>

<div class=3DSection1>

<p class=3DMsoNormal><font size=3D2 color=3Dnavy face=3DArial><span =
style=3D'font-size:
10.0pt;font-family:Arial;color:navy'>I can probably do it in two, but =
I&#8217;d
have to use syntax like that below, it uses the system to store a value =
between
record complex reads, you may have to set a variable named d2var to 0 =
before
running the quiz.<o:p></o:p></span></font></p>

<p class=3DMsoNormal><font size=3D2 color=3Dnavy face=3DArial><span =
style=3D'font-size:
10.0pt;font-family:Arial;color:navy'><o:p>&nbsp;</o:p></span></font></p>

<p class=3DMsoNormal style=3D'margin-left:36.0pt'><font size=3D2 =
color=3Dnavy
face=3DArial><span =
style=3D'font-size:10.0pt;font-family:Arial;color:navy'>Acc * sf1
link &#8230;etc&#8230; <o:p></o:p></span></font></p>

<p class=3DMsoNormal style=3D'margin-left:36.0pt'><font size=3D2 =
color=3Dnavy
face=3DArial><span =
style=3D'font-size:10.0pt;font-family:Arial;color:navy'><o:p>&nbsp;</o:p>=
</span></font></p>

<p class=3DMsoNormal style=3D'margin-left:36.0pt'><font size=3D2 =
color=3Dnavy
face=3DArial><span =
style=3D'font-size:10.0pt;font-family:Arial;color:navy'>Sort on =
median-item<o:p></o:p></span></font></p>

<p class=3DMsoNormal><font size=3D2 color=3Dnavy face=3DArial><span =
style=3D'font-size:
10.0pt;font-family:Arial;color:navy'><o:p>&nbsp;</o:p></span></font></p>

<p class=3DMsoNormal style=3D'margin-left:36.0pt'><font size=3D2 =
color=3Dnavy
face=3DArial><span =
style=3D'font-size:10.0pt;font-family:Arial;color:navy'>Define d1
char*15 =3D getsystemval(d2var) if record sf1 =
exists<o:p></o:p></span></font></p>

<p class=3DMsoNormal style=3D'margin-left:36.0pt'><font size=3D2 =
color=3Dnavy
face=3DArial><span =
style=3D'font-size:10.0pt;font-family:Arial;color:navy'><o:p>&nbsp;</o:p>=
</span></font></p>

<p class=3DMsoNormal style=3D'margin-left:36.0pt'><font size=3D2 =
color=3Dnavy
face=3DArial><span =
style=3D'font-size:10.0pt;font-family:Arial;color:navy'>Define d0
=3D tot-recs if nconvert (d1) =3D 0<o:p></o:p></span></font></p>

<p class=3DMsoNormal style=3D'margin-left:36.0pt'><font size=3D2 =
color=3Dnavy
face=3DArial><span =
style=3D'font-size:10.0pt;font-family:Arial;color:navy'><o:p>&nbsp;</o:p>=
</span></font></p>

<p class=3DMsoNormal style=3D'margin-left:36.0pt'><font size=3D2 =
color=3Dnavy
face=3DArial><span =
style=3D'font-size:10.0pt;font-family:Arial;color:navy'>Define d-rec-num
int * 8 =3D floor (tot-recs/2 ) if 0.5 lt mod ( d0 ,2 =
)<o:p></o:p></span></font></p>

<p class=3DMsoNormal style=3D'margin-left:36.0pt'><font size=3D2 =
color=3Dnavy
face=3DArial><span =
style=3D'font-size:10.0pt;font-family:Arial;color:navy'><o:p>&nbsp;</o:p>=
</span></font></p>

<p class=3DMsoNormal style=3D'margin-left:36.0pt'><font size=3D2 =
color=3Dnavy
face=3DArial><span =
style=3D'font-size:10.0pt;font-family:Arial;color:navy'>Define d3
int =3D nconvert (d1) + 1 if record sf1 =
exists<o:p></o:p></span></font></p>

<p class=3DMsoNormal style=3D'margin-left:36.0pt'><font size=3D2 =
color=3Dnavy
face=3DArial><span =
style=3D'font-size:10.0pt;font-family:Arial;color:navy'><o:p>&nbsp;</o:p>=
</span></font></p>

<p class=3DMsoNormal style=3D'margin-left:36.0pt'><font size=3D2 =
color=3Dnavy
face=3DArial><span =
style=3D'font-size:10.0pt;font-family:Arial;color:navy'>Define d2
char*15 =3D setsystemval(ascii (dvar)) if record sf1 =
exists<o:p></o:p></span></font></p>

<p class=3DMsoNormal style=3D'margin-left:36.0pt'><font size=3D2 =
color=3Dnavy
face=3DArial><span =
style=3D'font-size:10.0pt;font-family:Arial;color:navy'><o:p>&nbsp;</o:p>=
</span></font></p>

<p class=3DMsoNormal style=3D'margin-left:36.0pt'><font size=3D2 =
color=3Dnavy
face=3DArial><span =
style=3D'font-size:10.0pt;font-family:Arial;color:navy'>Define d-median
=3D median-item of sf1 if d3 =3D d-rec-num <o:p></o:p></span></font></p>

<p class=3DMsoNormal style=3D'margin-left:36.0pt'><font size=3D2 =
color=3Dnavy
face=3DArial><span =
style=3D'font-size:10.0pt;font-family:Arial;color:navy'><o:p>&nbsp;</o:p>=
</span></font></p>

<p class=3DMsoNormal style=3D'margin-left:36.0pt'><font size=3D2 =
color=3Dnavy
face=3DArial><span =
style=3D'font-size:10.0pt;font-family:Arial;color:navy'>Report =
d-median<o:p></o:p></span></font></p>

<p class=3DMsoNormal><font size=3D2 color=3Dnavy face=3DArial><span =
style=3D'font-size:
10.0pt;font-family:Arial;color:navy'><o:p>&nbsp;</o:p></span></font></p>

<p class=3DMsoNormal><font size=3D2 color=3Dnavy face=3DArial><span =
style=3D'font-size:
10.0pt;font-family:Arial;color:navy'>The first pass gets the total =
count, from
which the record position in the sorted file can be determined, the code =
above
selects the value matching the record id.<o:p></o:p></span></font></p>

<p class=3DMsoNormal><font size=3D2 color=3Dnavy face=3DArial><span =
style=3D'font-size:
10.0pt;font-family:Arial;color:navy'><o:p>&nbsp;</o:p></span></font></p>

<p class=3DMsoNormal><font size=3D2 color=3Dnavy face=3DArial><span =
style=3D'font-size:
10.0pt;font-family:Arial;color:navy'>First =
pass,<o:p></o:p></span></font></p>

<p class=3DMsoNormal><font size=3D2 color=3Dnavy face=3DArial><span =
style=3D'font-size:
10.0pt;font-family:Arial;color:navy'><o:p>&nbsp;</o:p></span></font></p>

<p class=3DMsoNormal><font size=3D2 color=3Dnavy face=3DArial><span =
style=3D'font-size:
10.0pt;font-family:Arial;color:navy'>Access f1 =
&#8230;<o:p></o:p></span></font></p>

<p class=3DMsoNormal><font size=3D2 color=3Dnavy face=3DArial><span =
style=3D'font-size:
10.0pt;font-family:Arial;color:navy'><o:p>&nbsp;</o:p></span></font></p>

<p class=3DMsoNormal><font size=3D2 color=3Dnavy face=3DArial><span =
style=3D'font-size:
10.0pt;font-family:Arial;color:navy'>Sort on median-item =
descending<o:p></o:p></span></font></p>

<p class=3DMsoNormal><font size=3D2 color=3Dnavy face=3DArial><span =
style=3D'font-size:
10.0pt;font-family:Arial;color:navy'><o:p>&nbsp;</o:p></span></font></p>

<p class=3DMsoNormal><font size=3D2 color=3Dnavy face=3DArial><span =
style=3D'font-size:
10.0pt;font-family:Arial;color:navy'>Define tot-recs =3D =
1<o:p></o:p></span></font></p>

<p class=3DMsoNormal><font size=3D2 color=3Dnavy face=3DArial><span =
style=3D'font-size:
10.0pt;font-family:Arial;color:navy'><o:p>&nbsp;</o:p></span></font></p>

<p class=3DMsoNormal><font size=3D2 color=3Dnavy face=3DArial><span =
style=3D'font-size:
10.0pt;font-family:Arial;color:navy'>Set sub name sf1 =
keep<o:p></o:p></span></font></p>

<p class=3DMsoNormal><font size=3D2 color=3Dnavy face=3DArial><span =
style=3D'font-size:
10.0pt;font-family:Arial;color:navy'><o:p>&nbsp;</o:p></span></font></p>

<p class=3DMsoNormal><font size=3D2 color=3Dnavy face=3DArial><span =
style=3D'font-size:
10.0pt;font-family:Arial;color:navy'>Rep summ median-item &nbsp;tot-recs
subtotal<o:p></o:p></span></font></p>

<p class=3DMsoNormal><font size=3D2 color=3Dnavy face=3DArial><span =
style=3D'font-size:
10.0pt;font-family:Arial;color:navy'><o:p>&nbsp;</o:p></span></font></p>

<p class=3DMsoNormal><font size=3D2 color=3Dnavy face=3DArial><span =
style=3D'font-size:
10.0pt;font-family:Arial;color:navy'><o:p>&nbsp;</o:p></span></font></p>

<div>

<div class=3DMsoNormal align=3Dcenter style=3D'text-align:center'><font =
size=3D3
face=3D"Times New Roman"><span style=3D'font-size:12.0pt'>

<hr size=3D3 width=3D"100%" align=3Dcenter tabindex=3D-1>

</span></font></div>

<p class=3DMsoNormal><b><font size=3D2 face=3DTahoma><span =
style=3D'font-size:10.0pt;
font-family:Tahoma;font-weight:bold'>From:</span></font></b><font =
size=3D2
face=3DTahoma><span style=3D'font-size:10.0pt;font-family:Tahoma'> =
<st1:PersonName
w:st=3D"on">powerh-l-admin@lists.sowder.com</st1:PersonName> =
[mailto:<st1:PersonName
w:st=3D"on">powerh-l-admin@lists.sowder.com</st1:PersonName>] <b><span
style=3D'font-weight:bold'>On Behalf Of </span></b>Deskin, Bob<br>
<b><span style=3D'font-weight:bold'>Sent:</span></b> 29 July 2004 =
12:26<br>
<b><span style=3D'font-weight:bold'>To:</span></b> PowerHouse List<br>
<b><span style=3D'font-weight:bold'>Subject:</span></b> RE: Calculating =
Median</span></font><o:p></o:p></p>

</div>

<p class=3DMsoNormal><font size=3D3 face=3D"Times New Roman"><span =
style=3D'font-size:
12.0pt'><o:p>&nbsp;</o:p></span></font></p>

<div>

<div>

<div>

<p class=3DMsoNormal><font size=3D2 color=3Dblue face=3DArial><span =
style=3D'font-size:
10.0pt;font-family:Arial;color:blue'>And then there's the QUIZ solution. =
Let's
say you want&nbsp;the median for item x. If the number of records is odd =
you
want the value of x for record (n+1)/2. If the number of records is =
even, you
want the average (sum divided by count)&nbsp;of the values of x for the =
two
records n/2 and (n/2)+1.</span></font><o:p></o:p></p>

</div>

<div>

<p class=3DMsoNormal><font size=3D3 face=3D"Times New Roman"><span =
style=3D'font-size:
12.0pt'>&nbsp;<o:p></o:p></span></font></p>

</div>

<div>

<p class=3DMsoNormal><font size=3D2 color=3Dblue face=3DArial><span =
style=3D'font-size:
10.0pt;font-family:Arial;color:blue'>I can do this report in 4 passes =
(remember
Name that Tune). Anyone for 3?</span></font><o:p></o:p></p>

</div>

<div>

<p class=3DMsoNormal><font size=3D3 face=3D"Times New Roman"><span =
style=3D'font-size:
12.0pt'>&nbsp;<o:p></o:p></span></font></p>

</div>

<div>

<p class=3DMsoNormal><font size=3D2 color=3Dblue face=3DArial><span =
style=3D'font-size:
10.0pt;font-family:Arial;color:blue'>Disclaimer: I have not tested this =
other
than in my head, and we all know what can happen when we only test in =
our heads
:-)</span></font><o:p></o:p></p>

</div>

<div>

<p class=3DMsoNormal><font size=3D3 face=3D"Times New Roman"><span =
style=3D'font-size:
12.0pt'>&nbsp;<o:p></o:p></span></font></p>

</div>

<div>

<p class=3DMsoNormal><font size=3D2 color=3Dblue face=3DArial><span =
style=3D'font-size:
10.0pt;font-family:Arial;color:blue'>access =
file</span></font><o:p></o:p></p>

</div>

<div>

<p class=3DMsoNormal><font size=3D2 color=3Dblue face=3DArial><span =
style=3D'font-size:
10.0pt;font-family:Arial;color:blue'>sort on =
x</span></font><o:p></o:p></p>

</div>

<div>

<p class=3DMsoNormal><font size=3D2 color=3Dblue face=3DArial><span =
style=3D'font-size:
10.0pt;font-family:Arial;color:blue'>define x-count integer =3D =
1</span></font><o:p></o:p></p>

</div>

<div>

<p class=3DMsoNormal><font size=3D2 color=3Dblue face=3DArial><span =
style=3D'font-size:
10.0pt;font-family:Arial;color:blue'>report summary x x-count =
subtotal</span></font><o:p></o:p></p>

</div>

<div>

<p class=3DMsoNormal><font size=3D2 color=3Dblue face=3DArial><span =
style=3D'font-size:
10.0pt;font-family:Arial;color:blue'>set subfile name =
xsub</span></font><o:p></o:p></p>

</div>

<div>

<p class=3DMsoNormal><font size=3D2 color=3Dblue face=3DArial><span =
style=3D'font-size:
10.0pt;font-family:Arial;color:blue'>go&nbsp; ; this gives the values in
sequence with&nbsp;a sequence number</span></font><o:p></o:p></p>

</div>

<div>

<p class=3DMsoNormal><font size=3D3 face=3D"Times New Roman"><span =
style=3D'font-size:
12.0pt'>&nbsp;<o:p></o:p></span></font></p>

</div>

<div>

<p class=3DMsoNormal><font size=3D2 color=3Dblue face=3DArial><span =
style=3D'font-size:
10.0pt;font-family:Arial;color:blue'>access =
*xsub</span></font><o:p></o:p></p>

</div>

<div>

<p class=3DMsoNormal><font size=3D2 color=3Dblue face=3DArial><span =
style=3D'font-size:
10.0pt;font-family:Arial;color:blue'>define n =3D =
1</span></font><o:p></o:p></p>

</div>

<div>

<p class=3DMsoNormal><font size=3D2 color=3Dblue face=3DArial><span =
style=3D'font-size:
10.0pt;font-family:Arial;color:blue'>define x-1 =3D =
1</span></font><o:p></o:p></p>

</div>

<div>

<p class=3DMsoNormal><font size=3D2 color=3Dblue face=3DArial><span =
style=3D'font-size:
10.0pt;font-family:Arial;color:blue'>sorted on =
x-1</span></font><o:p></o:p></p>

</div>

<div>

<p class=3DMsoNormal><font size=3D2 color=3Dblue face=3DArial><span =
style=3D'font-size:
10.0pt;font-family:Arial;color:blue'>report summary n =
subtotal</span></font><o:p></o:p></p>

</div>

<div>

<p class=3DMsoNormal><font size=3D2 color=3Dblue face=3DArial><span =
style=3D'font-size:
10.0pt;font-family:Arial;color:blue'>set subfile name xtotal at =
x-1&nbsp; ;
this is the same as AT FINAL which QUIZ doesn't =
have</span></font><o:p></o:p></p>

</div>

<div>

<p class=3DMsoNormal><font size=3D2 color=3Dblue face=3DArial><span =
style=3D'font-size:
10.0pt;font-family:Arial;color:blue'>go&nbsp; ; this gives the total =
count n</span></font><o:p></o:p></p>

</div>

<div>

<p class=3DMsoNormal><font size=3D3 face=3D"Times New Roman"><span =
style=3D'font-size:
12.0pt'>&nbsp;<o:p></o:p></span></font></p>

</div>

<div>

<p class=3DMsoNormal><font size=3D2 color=3Dblue face=3DArial><span =
style=3D'font-size:
10.0pt;font-family:Arial;color:blue'>access =
xtotal</span></font><o:p></o:p></p>

</div>

<div>

<p class=3DMsoNormal><font size=3D2 color=3Dblue face=3DArial><span =
style=3D'font-size:
10.0pt;font-family:Arial;color:blue'>define x-med1 integer&nbsp;=3D (n + =
1)/2 if
1 =3D mod(n,2) else n/2</span></font><o:p></o:p></p>

</div>

<div>

<p class=3DMsoNormal><font size=3D2 color=3Dblue face=3DArial><span =
style=3D'font-size:
10.0pt;font-family:Arial;color:blue'>define x-med2 integer =3D (n + 1)/2 =
if 1 =3D
mod(n,2) else (n/2) + 1&nbsp;</span></font><o:p></o:p></p>

</div>

<div>

<p class=3DMsoNormal><font size=3D2 color=3Dblue face=3DArial><span =
style=3D'font-size:
10.0pt;font-family:Arial;color:blue'>define x-1 =3D =
1</span></font><o:p></o:p></p>

</div>

<div>

<p class=3DMsoNormal><font size=3D2 color=3Dblue face=3DArial><span =
style=3D'font-size:
10.0pt;font-family:Arial;color:blue'>sorted on =
x-1</span></font><o:p></o:p></p>

</div>

<div>

<p class=3DMsoNormal><font size=3D2 color=3Dblue face=3DArial><span =
style=3D'font-size:
10.0pt;font-family:Arial;color:blue'>report summary x-med1 =
x-med2</span></font><o:p></o:p></p>

</div>

<div>

<div>

<p class=3DMsoNormal><font size=3D2 color=3Dblue face=3DArial><span =
style=3D'font-size:
10.0pt;font-family:Arial;color:blue'>set subfile name xmedian at =
x-1</span></font><o:p></o:p></p>

</div>

<p class=3DMsoNormal><font size=3D2 color=3Dblue face=3DArial><span =
style=3D'font-size:
10.0pt;font-family:Arial;color:blue'>go&nbsp; ; this gives the record =
numbers
of the one or two records you want</span></font><o:p></o:p></p>

</div>

<div>

<p class=3DMsoNormal><font size=3D3 face=3D"Times New Roman"><span =
style=3D'font-size:
12.0pt'>&nbsp;<o:p></o:p></span></font></p>

</div>

<div>

<p class=3DMsoNormal><font size=3D2 color=3Dblue face=3DArial><span =
style=3D'font-size:
10.0pt;font-family:Arial;color:blue'>set =
nosubfile</span></font><o:p></o:p></p>

</div>

<div>

<p class=3DMsoNormal><font size=3D2 color=3Dblue face=3DArial><span =
style=3D'font-size:
10.0pt;font-family:Arial;color:blue'>access *xsub link to record 0 of
xmedian&nbsp; ; record 1 on OpenVMS and =
OS/400</span></font><o:p></o:p></p>

</div>

<div>

<p class=3DMsoNormal><font size=3D2 color=3Dblue face=3DArial><span =
style=3D'font-size:
10.0pt;font-family:Arial;color:blue'>select if x-count =3D x-med1 or =
x-count =3D
x-med2</span></font><o:p></o:p></p>

</div>

<div>

<p class=3DMsoNormal><font size=3D2 color=3Dblue face=3DArial><span =
style=3D'font-size:
10.0pt;font-family:Arial;color:blue'>; if x-med1 =3D x-med2 only one =
record will
be selected</span></font><o:p></o:p></p>

</div>

<div>

<p class=3DMsoNormal><font size=3D2 color=3Dblue face=3DArial><span =
style=3D'font-size:
10.0pt;font-family:Arial;color:blue'>; if x-med1 &lt;&gt; x-med2 two =
records
will be selected</span></font><o:p></o:p></p>

</div>

<div>

<p class=3DMsoNormal><font size=3D2 color=3Dblue face=3DArial><span =
style=3D'font-size:
10.0pt;font-family:Arial;color:blue'>report x average x-med1 =
x-med2</span></font><o:p></o:p></p>

</div>

<div>

<p class=3DMsoNormal><font size=3D2 color=3Dblue face=3DArial><span =
style=3D'font-size:
10.0pt;font-family:Arial;color:blue'>go&nbsp; ; this gives the =
median</span></font><o:p></o:p></p>

</div>

<div>

<p class=3DMsoNormal><font size=3D3 face=3D"Times New Roman"><span =
style=3D'font-size:
12.0pt'>&nbsp;<o:p></o:p></span></font></p>

</div>

<div>

<p><font size=3D2 color=3Dblue face=3DArial><span =
style=3D'font-size:10.0pt;font-family:
Arial;color:blue'>Bob
Deskin&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&=
nbsp;&nbsp;
<br>
Senior Product Manager, Application Development Tools <br>
Cognos Inc. 3755 Riverside Drive, Ottawa ON K1G 4K9 CANADA <br>
bob.deskin@cognos.com (613) 738-1338 ext 7268 =
</span></font><o:p></o:p></p>

</div>

</div>

<blockquote =
style=3D'margin-top:5.0pt;margin-right:0cm;margin-bottom:5.0pt'>

<p class=3DMsoNormal style=3D'margin-bottom:12.0pt'><font size=3D2 =
face=3DTahoma><span
style=3D'font-size:10.0pt;font-family:Tahoma'>-----Original =
Message-----<br>
<b><span style=3D'font-weight:bold'>From:</span></b> <st1:PersonName =
w:st=3D"on">powerh-l-admin@lists.sowder.com</st1:PersonName>
[mailto:<st1:PersonName =
w:st=3D"on">powerh-l-admin@lists.sowder.com</st1:PersonName>]<b><span
style=3D'font-weight:bold'>On Behalf Of </span></b>Robert Edis<br>
<b><span style=3D'font-weight:bold'>Sent:</span></b> July 28, 2004 7:11 =
PM<br>
<b><span style=3D'font-weight:bold'>To:</span></b> PowerHouse List<br>
<b><span style=3D'font-weight:bold'>Subject:</span></b> RE: Calculating =
Median</span></font><o:p></o:p></p>

<div>

<p class=3DMsoNormal><font size=3D3 face=3D"Times New Roman"><span =
style=3D'font-size:
12.0pt'>No, no, no ... I'm innocent I tell =
you!<o:p></o:p></span></font></p>

</div>

<div>

<p class=3DMsoNormal><font size=3D3 face=3D"Times New Roman"><span =
style=3D'font-size:
12.0pt'>&nbsp;<o:p></o:p></span></font></p>

</div>

<div>

<p class=3DMsoNormal><font size=3D3 face=3D"Times New Roman"><span =
style=3D'font-size:
12.0pt'>Ordinarily I would agree but in this particular case I suggest =
Quick
because of simplicity.&nbsp; Exception-to-the-rule and all =
that.<o:p></o:p></span></font></p>

</div>

<div>

<p class=3DMsoNormal><font size=3D3 face=3D"Times New Roman"><span =
style=3D'font-size:
12.0pt'>&nbsp;<o:p></o:p></span></font></p>

</div>

<div>

<p class=3DMsoNormal><font size=3D3 face=3D"Times New Roman"><span =
style=3D'font-size:
12.0pt'>Of couse I could of suggested using a 3GL tool - an external =
function
if you like. :)<o:p></o:p></span></font></p>

</div>

<div>

<p class=3DMsoNormal><font size=3D3 face=3D"Times New Roman"><span =
style=3D'font-size:
12.0pt'>&nbsp;<o:p></o:p></span></font></p>

</div>

<div>

<p class=3DMsoNormal><font size=3D3 face=3D"Times New Roman"><span =
style=3D'font-size:
12.0pt'>Blue<br>
<br>
<b><i><span style=3D'font-weight:bold;font-style:italic'>David Morrison =
-
Corporate &lt;dmorrison@mcbrideelectric.com&gt;</span></i></b> =
wrote:<o:p></o:p></span></font></p>

</div>

<blockquote style=3D'border:none;border-left:solid #1010FF =
1.5pt;padding:0cm 0cm 0cm 3.0pt;
margin-left:3.0pt;margin-top:5.0pt;margin-bottom:5.0pt'>

<p class=3DMsoNormal><span class=3DEmailStyle17><font size=3D2 =
color=3Dnavy face=3DArial><span
style=3D'font-size:10.0pt'>Blue,<u1:p></u1:p></span></font></span><o:p></=
o:p></p>

<p class=3DMsoNormal><span class=3DEmailStyle17><font size=3D2 =
color=3Dnavy face=3DArial><span
style=3D'font-size:10.0pt'>&nbsp;<u1:p></u1:p></span></font></span><o:p><=
/o:p></p>

<p class=3DMsoNormal><span class=3DEmailStyle17><font size=3D2 =
color=3Dnavy face=3DArial><span
style=3D'font-size:10.0pt'>Ah, you&#8217;re just trying to start trouble =
on the
list-serve aren&#8217;t you!&nbsp; Didn&#8217;t we just have a =
discussion about
why not to use QUICK when QTP or QUIZ will do (and I was on the side of =
the
QUICK solution)?<u1:p></u1:p></span></font></span><o:p></o:p></p>

<p class=3DMsoNormal><span class=3DEmailStyle17><font size=3D2 =
color=3Dnavy face=3DArial><span
style=3D'font-size:10.0pt'>&nbsp;<u1:p></u1:p></span></font></span><o:p><=
/o:p></p>

<p class=3DMsoNormal><span class=3DEmailStyle17><font size=3D2 =
color=3Dnavy face=3DArial><span
style=3D'font-size:10.0pt'>Cordially,<u1:p></u1:p></span></font></span><o=
:p></o:p></p>

<p class=3DMsoNormal><span class=3DEmailStyle17><font size=3D2 =
color=3Dnavy face=3DArial><span
style=3D'font-size:10.0pt'>&nbsp;<u1:p></u1:p></span></font></span><o:p><=
/o:p></p>

<p class=3DMsoAutoSig><font size=3D3 color=3Dnavy face=3D"Times New =
Roman"><span
style=3D'font-size:12.0pt;color:navy'>David =
Morrison</span></font><o:p></o:p></p>

<u1:p></u1:p>

<p class=3DMsoAutoSig><font size=3D3 color=3Dnavy face=3D"Times New =
Roman"><span
style=3D'font-size:12.0pt;color:navy'>McBride =
Electric</span></font><o:p></o:p></p>

<u1:p></u1:p>

<p class=3DMsoNormal><span class=3DEmailStyle17><font size=3D2 =
color=3Dnavy face=3DArial><span
style=3D'font-size:10.0pt'>&nbsp;<u1:p></u1:p></span></font></span><o:p><=
/o:p></p>

<p class=3DMsoNormal style=3D'margin-left:36.0pt'><font size=3D2 =
color=3Dblack
face=3DTahoma><span =
style=3D'font-size:10.0pt;font-family:Tahoma;color:black'>-----Original
Message-----<br>
<b><span style=3D'font-weight:bold'>From:</span></b> <st1:PersonName =
w:st=3D"on">powerh-l-admin@lists.sowder.com</st1:PersonName>
[mailto:<st1:PersonName =
w:st=3D"on">powerh-l-admin@lists.sowder.com</st1:PersonName>]<b><span
style=3D'font-weight:bold'>On Behalf Of </span></b>Robert Edis<br>
<b><span style=3D'font-weight:bold'>Sent:</span></b> Wednesday, July 28, =
2004
1:48 PM<br>
<b><span style=3D'font-weight:bold'>To:</span></b> PowerHouse List<br>
<b><span style=3D'font-weight:bold'>Subject:</span></b> RE: Calculating =
Median</span></font><o:p></o:p></p>

<p class=3DMsoNormal style=3D'margin-left:36.0pt'><font size=3D3
face=3D"Times New Roman"><span =
style=3D'font-size:12.0pt'>&nbsp;<u1:p></u1:p><o:p></o:p></span></font></=
p>

<p class=3DMsoNormal style=3D'margin-left:36.0pt'><font size=3D3 =
color=3Dblack
face=3D"Times New Roman"><span =
style=3D'font-size:12.0pt;color:black'>Why do it in
Quick?&nbsp; Then you have looping, designer files, and temporary =
variables
available for the logic.&nbsp; No subfile is required and all processing =
can be
done in designer procedures.&nbsp; </span></font><o:p></o:p></p>

<u1:p></u1:p>

<p class=3DMsoNormal style=3D'margin-left:36.0pt'><font size=3D3 =
color=3Dblack
face=3D"Times New Roman"><span =
style=3D'font-size:12.0pt;color:black'>&nbsp;</span></font><o:p></o:p></p=
>

<u1:p></u1:p>

<p class=3DMsoNormal style=3D'margin-left:36.0pt'><font size=3D3 =
color=3Dblack
face=3D"Times New Roman"><span =
style=3D'font-size:12.0pt;color:black'>Added bonus
is that user can run screen and get median value any time they choose =
without
MIS getting involved.</span></font><o:p></o:p></p>

<u1:p></u1:p>

<p class=3DMsoNormal style=3D'margin-left:36.0pt'><font size=3D3 =
color=3Dblack
face=3D"Times New Roman"><span =
style=3D'font-size:12.0pt;color:black'>&nbsp;</span></font><o:p></o:p></p=
>

<u1:p></u1:p>

<p class=3DMsoNormal style=3D'margin-left:36.0pt'><font size=3D3 =
color=3Dblack
face=3D"Times New Roman"><span =
style=3D'font-size:12.0pt;color:black'>Blue<br>
<br>
<b><i><span style=3D'font-weight:bold;font-style:italic'>David Morrison =
-
Corporate &lt;dmorrison@mcbrideelectric.com&gt;</span></i></b> =
wrote:</span></font><o:p></o:p></p>

<u1:p></u1:p>

<div style=3D'border:none;border-left:solid #1010FF 1.5pt;padding:0cm =
0cm 0cm 4.0pt'>

<div style=3D'mso-element:para-border-div;border:none;border-left:solid =
#1010FF 1.5pt;
padding:0cm 0cm 0cm 4.0pt;margin-left:39.75pt;margin-right:36.0pt'>

<p class=3DMsoNormal =
style=3D'mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;
border:none;padding:0cm'><font size=3D3 color=3Dblack face=3D"Times New =
Roman"><span
style=3D'font-size:12.0pt;color:black'>Blair,<br>
<br>
How about something like this:<br>
<br>
Use a QTP program that does the following:<br>
<br>
1. First request: Sort the data on the value that you're looking to get =
the
median for. Output records to a sub-file at that value, outputting the =
value
and COUNT RESET. Put COUNT NORESET into a global temporary item. <br>
<br>
2. Second request: Read the sub-file created in the previous step =
(they're
already sorted). Accumulate the total of the counted field in each =
record.
Compare that to the global tempor! ary; when it reaches 1/2 of that =
total, you
have the median value. <br>
<br>
<br>
David Morrison<br>
McBride Electric<br>
<br>
-----Original Message-----<br>
From: <st1:PersonName =
w:st=3D"on">powerh-l-admin@lists.sowder.com</st1:PersonName>
[mailto:<st1:PersonName =
w:st=3D"on">powerh-l-admin@lists.sowder.com</st1:PersonName>]
On Behalf Of Blair Combs<br>
Sent: Wednesday, July 28, 2004 12:23 PM<br>
To: Powerhouse Listserv<br>
Subject: Calculating Median<br>
<br>
Does anyone ha! ve an idea on how to calculate the Median for a list of =
<br>
numbers using Quiz?<br>
<br>
Blair Combs<br>
<st1:place w:st=3D"on"><st1:PlaceName w:st=3D"on">Idaho</st1:PlaceName> =
<st1:PlaceType
 w:st=3D"on">State</st1:PlaceType> <st1:PlaceType =
w:st=3D"on">University</st1:PlaceType></st1:place><br>
<br>
=3D =3D =3D =3D =3D =3D =3D =3D =3D =3D =3D =3D =3D =3D =3D =3D =3D =3D =
=3D =3D =3D =3D =3D =3D =3D =3D =3D =3D<br>
Mailing list: powerh-l@lists.sowder.com<br>
Subscribe: &quot;subscribe&quot; in message body to
powerh-l-request@lists.sowder.com<br>
Unsubscribe: &quot;unsubscribe <PASSWORD>&quot; in message body to
powerh-l-request@lists.sowder.com<br>
http://lists.sowder.com/mailman/listinfo/powerh-l<br>
This list is closed, thus to post to the list you must be a =
subscriber.<br>
<br>
<br>
<br>
=3D =3D =3D =3D =3D =3D =3D =3D =3D =3D =3D =3D =3D =3D =3D =3D =3D =3D =
=3D =3D =3D =3D =3D =3D =3D =3D =3D =3D<br>
Mailing list: powerh-l@lists.sowder.com<br>
Subscribe: &quot;subscribe&quot; in message body to
powerh-l-request@lists.sowder.com<br>
Unsubscribe: &quot;unsubscribe <PASSWORD>&quot; in message body to
powerh-l-request@lists.sowder.com<br>
http://lists.sowder.com/mailman/listinfo/powerh-l<br>
This list is closed, thus to post to the list you must be a =
subscriber.</span></font><o:p></o:p></p>

</div>

</div>

</blockquote>

</blockquote>

</div>

<u1:p></u1:p>

<div>

<p class=3DMsoNormal><font size=3D3 face=3D"Times New Roman"><span =
style=3D'font-size:
12.0pt'>&nbsp;<o:p></o:p></span></font></p>

</div>

<div>

<p><font size=3D3 face=3D"Times New Roman"><span =
style=3D'font-size:12.0pt'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</sp=
an></font><font
size=3D2 face=3DArial><span =
style=3D'font-size:10.0pt;font-family:Arial'>This message
may contain privileged and/or confidential information.&nbsp; If you =
have
received this e-mail in error or are not the intended recipient, you may =
not
use, copy, disseminate or distribute it; do not open any attachments, =
delete it
immediately from your system and notify the sender promptly by e-mail =
that you
have done so.&nbsp; Thank you.</span></font> <o:p></o:p></p>

</div>

</div>

</body>

</html>

------=_NextPart_000_0000_01C479AD.15E30880--