COMPGROUPS.NET | Search | Post Question | Groups | Stream | About | Register

### Calulating Average for previous and next value

• Email
• Follow

```Hi,

I need to calculate Average as shown in below table,
by zone and time.

Average should be of previous and the next number
for ex: for zone A for time 00:30 it is average of demand of time
00:15 and 00:45.

Time	Zone	demand	Average
0:15	A	10	10
0:30	A	20	20
0:45	A	30	17.5
0:15	B	15	15
0:30	B	18	17.5
0:45	B	20	17.5
0:15	C	17	17
0:30	C	19	19
0:45	C	21	11
0:15	D	3	3
0:30	D	8	11
0:45	D	19	8

thanks
```
 0
Reply atulrill (15) 8/21/2010 3:42:35 PM

See related articles to this posting

```Either I don't understand what you are trying to do, or you have not

Please show what each average is supposed to be an average of and why
the calculations appear to be different for different zones.

Art
---------
On Aug 21, 11:42=A0am, atulrill <atulr...@gmail.com> wrote:
> Hi,
>
> I need to calculate Average as shown in below table,
> by zone and time.
>
> Average should be of previous and the next number
> for ex: for zone A for time 00:30 it is average of demand of time
> 00:15 and 00:45.
>
> Time =A0 =A0Zone =A0 =A0demand =A0Average
> 0:15 =A0 =A0A =A0 =A0 =A0 10 =A0 =A0 =A010
> 0:30 =A0 =A0A =A0 =A0 =A0 20 =A0 =A0 =A020
> 0:45 =A0 =A0A =A0 =A0 =A0 30 =A0 =A0 =A017.5
> 0:15 =A0 =A0B =A0 =A0 =A0 15 =A0 =A0 =A015
> 0:30 =A0 =A0B =A0 =A0 =A0 18 =A0 =A0 =A017.5
> 0:45 =A0 =A0B =A0 =A0 =A0 20 =A0 =A0 =A017.5
> 0:15 =A0 =A0C =A0 =A0 =A0 17 =A0 =A0 =A017
> 0:30 =A0 =A0C =A0 =A0 =A0 19 =A0 =A0 =A019
> 0:45 =A0 =A0C =A0 =A0 =A0 21 =A0 =A0 =A011
> 0:15 =A0 =A0D =A0 =A0 =A0 3 =A0 =A0 =A0 3
> 0:30 =A0 =A0D =A0 =A0 =A0 8 =A0 =A0 =A0 11
> 0:45 =A0 =A0D =A0 =A0 =A0 19 =A0 =A0 =A08
>
> thanks

```
 0
Reply art297 (4237) 8/21/2010 4:04:21 PM

```On Aug 21, 9:04=A0pm, Arthur Tabachneck <art...@netscape.net> wrote:
> Either I don't understand what you are trying to do, or you have not
> completed your average values correctly.
>
> Please show what each average is supposed to be an average of and why
> the calculations appear to be different for different zones.
>
> Art
> ---------
> On Aug 21, 11:42=A0am, atulrill <atulr...@gmail.com> wrote:
>
>
>
> > Hi,
>
> > I need to calculate Average as shown in below table,
> > by zone and time.
>
> > Average should be of previous and the next number
> > for ex: for zone A for time 00:30 it is average of demand of time
> > 00:15 and 00:45.
>
> > Time =A0 =A0Zone =A0 =A0demand =A0Average
> > 0:15 =A0 =A0A =A0 =A0 =A0 10 =A0 =A0 =A010
> > 0:30 =A0 =A0A =A0 =A0 =A0 20 =A0 =A0 =A020
> > 0:45 =A0 =A0A =A0 =A0 =A0 30 =A0 =A0 =A017.5
> > 0:15 =A0 =A0B =A0 =A0 =A0 15 =A0 =A0 =A015
> > 0:30 =A0 =A0B =A0 =A0 =A0 18 =A0 =A0 =A017.5
> > 0:45 =A0 =A0B =A0 =A0 =A0 20 =A0 =A0 =A017.5
> > 0:15 =A0 =A0C =A0 =A0 =A0 17 =A0 =A0 =A017
> > 0:30 =A0 =A0C =A0 =A0 =A0 19 =A0 =A0 =A019
> > 0:45 =A0 =A0C =A0 =A0 =A0 21 =A0 =A0 =A011
> > 0:15 =A0 =A0D =A0 =A0 =A0 3 =A0 =A0 =A0 3
> > 0:30 =A0 =A0D =A0 =A0 =A0 8 =A0 =A0 =A0 11
> > 0:45 =A0 =A0D =A0 =A0 =A0 19 =A0 =A0 =A08
>
> > thanks- Hide quoted text -
>
> - Show quoted text -

okkk forget d zone ,how to calculate atleast the average part
```
 0
Reply atulrill (15) 8/21/2010 4:17:40 PM

```"atulrill" <atulrill@gmail.com> wrote in message
> Hi,
>
> I need to calculate Average as shown in below table,
> by zone and time.
>
> Average should be of previous and the next number
> for ex: for zone A for time 00:30 it is average of demand of time
> 00:15 and 00:45.
>
> Time Zone demand Average
> 0:15 A 10 10
> 0:30 A 20 20
> 0:45 A 30 17.5
> 0:15 B 15 15
> 0:30 B 18 17.5
> 0:45 B 20 17.5
> 0:15 C 17 17
> 0:30 C 19 19
> 0:45 C 21 11
> 0:15 D 3 3
> 0:30 D 8 11
> 0:45 D 19 8
>
>
Is it any record before and after the current row?  What if you are at 0.30
and the 0.15 above is missing?

```
 0

```-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Am 21.08.2010 18:17, schrieb atulrill:
> On Aug 21, 9:04 pm, Arthur Tabachneck <art...@netscape.net> wrote:
>> Either I don't understand what you are trying to do, or you have not
>> completed your average values correctly.
>>
>> Please show what each average is supposed to be an average of and why
>> the calculations appear to be different for different zones.
>>
>> Art
>> ---------
>> On Aug 21, 11:42 am, atulrill <atulr...@gmail.com> wrote:
>>
>>
>>
>>> Hi,
>>
>>> I need to calculate Average as shown in below table,
>>> by zone and time.
>>
>>> Average should be of previous and the next number
>>> for ex: for zone A for time 00:30 it is average of demand of time
>>> 00:15 and 00:45.
>>
>>> Time    Zone    demand  Average
>>> 0:15    A       10      10
>>> 0:30    A       20      20
>>> 0:45    A       30      17.5
>>> 0:15    B       15      15
>>> 0:30    B       18      17.5
>>> 0:45    B       20      17.5
>>> 0:15    C       17      17
>>> 0:30    C       19      19
>>> 0:45    C       21      11
>>> 0:15    D       3       3
>>> 0:30    D       8       11
>>> 0:45    D       19      8
>>
>>> thanks- Hide quoted text -
>>
>> - Show quoted text -
>
> okkk forget d zone ,how to calculate atleast the average part

Hmmm, may be some combination of retaining values (retain statement /
lag2 function) would help. Not sure about - please let me know.
HTH, Lutz

data calc_avg (keep= record_no Average where= (record_no > 0));
set ... ;
record_no = _N_ - 1;
Average = mean (demand, max (0, lag2 (demand)));
run;

data ...;
set ...;
record_no = _N_;
run;

data ...;
merge ...
calc_avg;
by record_no;
run;

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iQEcBAEBAgAGBQJMgW7bAAoJEGHkKkg1pkZ2AgcH/0G3xw3yoX92cHtKSvesVFwj
CfltafRKYe7X6MIZjJZotIqMe8VZqUoHOIbf7r5ks940DVEeM8B2/zPgqVvNu+Gz
Q1dYT8hQ6zXb7LxGtMFRXAjnp/+LqOXgMfVbx6kDlI/uog6JOuMJZG1hQyll1sGr
QSwC/kk43fFPxGR/88h3uMYpl3MjHBLA4ZYQOULTQYGvusJoUyOpn4eYbXFTuTir
gtiMi1HKFExUW/66PF/KCP+N4w35dYT+QWTguhuodKanO5tddgmEHnoNNTas4Ko4
xmAxym+7PchSXjcpFw59yiHqp+/qZ8Xgm5PIeajceCcrHq+yxM9yuLxGkqEjEq4=
=b3P1
-----END PGP SIGNATURE-----
```
 0
Reply lutz2740 (1) 9/3/2010 9:55:40 PM

4 Replies
812 Views

Similar Articles

12/10/2013 10:07:03 PM
page loaded in 138335 ms. (0)

Similar Artilces:

How to use previous values?
I'm fairly new to Matlab, so perhaps my question seems stupid. I have over 1000 values from an Excel-file imported into Matlab. Now I want to create a plot wich displays a start value of 200 and then decreases with the values from the Excel-file. For example: Values from Excel are 10 20 40 20 5 25 Now I want to plot the following values: 200-10 200-10-20 200-10-20-40 200-10-20-40-20 200-10-20-40-20-5 200-10-20-40-20-5-25 How can I do this? Thanks in advance. "Gert-Leon " <glvanlier@gmail.com> wrote in message news:jpd7iu\$rt4\$1@newscl01ah.mathworks.com... > I'...

Copy value from previous record?
I have a field set up with the auto-enter option "copy value from previous record". Exactly _which_ record is "previous"... the help file doesn't say. I guess I assumed it was the last one entered. When I create a new record in this file from a portal in another related file, I can't see any rhyme or reason to the value that gets put in here. Thanks, Steve Hi Steve The online help says "the previously accessed record" but this only seems to when you are working in the child file. My attempts to make it work via a new record made on the last porta...

current versus previous value
Hi all SAS users. This may seem easy but I dunno how to do it. Could anyone please give me some guidance? I would like to know if the current "A" value is less than its previous value. if so, then flag=1. ID A 1 1 1 -0.5 1 -0.6 1 2 2 3 2 4 2 1 2 5 so the result is ID A flag 1 1 0 1 -0.5 1 1 -0.6 1 1 2 0 2 3 0 2 4 0 2 1 1 2 5 0 Thanks in advance. Have a great weekend. On May 7, 12:40=A0am, Ching <kcwo...@gmail.com> wrote: > Hi all SAS users. > > This may seem easy but I dunno how to do it. Could anyone please give > me some guidance...

how can I retrieve value of next occurence?
I'm using Excel 2007 and s/s is 325501 rows deep. It consists of series of ranges between 4 and 30 rows deep. I want to locate the next appearance of the name in column C and copy a number on same row in column L to column Q on the row of former appearance. The desired objective is to place in column Q the next appearing number in column L of the name in column C. When the next appearance presents no number I need to find the next appearance which does have a number. Doing this manully is not feasible, given the large size of the s/s . If anyone can help me to this end ...

How to find the max number from a set of average values?
Number State 10 CA 20 CA 30 CA 10 NY 20 NY 30 NY 40 NY If I have two fields - number and state, as the above table, how can I find the max number from the average values group by state? I use the following statement to get the averages: select avg(number) from table group by state The result: 20 25 But I am having problem get the maximum values from these two numbers (which should be 25). Could anyone help? SQL Learner A few methods: SELECT MAX(avg_number) AS max_avg_number FROM ( SELECT state, AVG(number) AS avg_number FROM Foo GROUP BY state) AS F; ...

Locking values in value lists?
I would like to allow users to select only specific values in a value list. Users would have uniqu access passwords and all users would have access to the value list, only that I don't want them to be able to select certain values from the value list. Any way to do this? Example: VALUE LIST: low med high prog lost active inactive User #1 can only select the top three values User #2 can selcet any value User #3 can select only the fith value User #4 can select value one and value six etc., LMK On Tue, 09 Nov 2004 11:45:15 -0800, tester wrote: > Any way to do this? > User #1 c...

is it possible to get hidden parameter values using window.opener.document.form.parameter.value.
is it possible to get hidden parameter values using window.opener.document.form.parameter.value. I am getting this error " Object not found" Please help Abdul Abdul Mohsin said: > >is it possible to get hidden parameter values using >window.opener.document.form.parameter.value. Yes. ...

converting value
Hi every one..... please help me to settle my prolem. If i have 16 level value as below; ['0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15']; then how to convert it to this value [0 0.2 1.0 2.1 3.2 4.9 7.5 11.5 17.8 27.3 42.1 64.8 99.9 153.8 236.8 364.6]; where; 0=0, 1=0.2, 2=1.0, 3=2.1, 4=3.2, 5=4.9, 6=7.5, 7=11.5, 8=17.8, 9=27.3, 10=42.1, 11=64.8, 12=99.9, 13=153.8, 14=236.8, and 15=364.6. TQ... On 25/01/11 10:47 PM, mat kamaruzaman wrote: > please help me to settle my prolem. If i have 16 level value as below; > > ['0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15...

next node
Lets say we have this: <h4 onclick="findFollowingNode()">Find next node</h4> <div>I want to get this node, (the div wrapper) so I can toggle visibility</div> It's been a while since I've written any DOM javascript and I simply don't remember how to get the next (non text) node. Or at least what I remember is wrong. Google is full of unhelpful debris, at least the way I'm searching. A pointer to code or a good DOM reference would be appreciated. Jeff Jeff wrote: > Lets say we have this: > > <h4 onclick="findF...

Getting Values
I have an array \$family there are 30 keys and associated values. I want to return the values from the last 8 items ( keys 'child1 - child8') and I am returning the age associated with each without referencing the keys just the element number 22 .. 30 print \$family{'child1'} ==> 28 ** age print \$family[22] ==> child1=29 I have attempted to get this info from the perldoc but without success. Might not be phrasing the question properly. I have not seen anything in the books I have. Help appreciated. Frank "Frank J. Russo" <FJRussonc@earthlink.net&...

default values
Hello All, Where can I find various default values, especially those to do with glortho and glfrustum. Any comments gratefully received. Ivan ivan danicic wrote: > Hello All, Where can I find various default values, especially those to do > with glortho and glfrustum. Any comments gratefully received. > Ivan > There are no default values for OpenGL calls. They are intended to be callable in any language, even those that don't have the ability to use default values for missing arguments. -- Andy V Andy V wrote: > ivan danicic wrote: >> Hello All, Where can I fin...

If value is in a list
I have a list of numbers, e.g., (1,3,4,5,8,16,20), and am trying to create a simple IF statement to see if the value is in that list. Is there an easier or more efficient way, than the sample code below, to do it? ===== <script type="text/javascript"> num = 2; list = [1,3,4,5,8,16,20]; if(isInList( num, list )) { alert("It's there!"); } else { alert("It's NOT there!"); } function isInList( num, list ) { // List is an Array() result = false; for(i in list) { if(num == list[i]) { result = true } } return result } </scr...

Next DVD Generation
Still only (guffaw) 36x the current cd-rom capacity but another welcome step up in permanent mass storage. http://news.bbc.co.uk/1/hi/technology/4362906.stm ...

map with multiple values
Hi, Suppose I have a vector, and I want to apply a function that returns multiple values to each element and get the result as a matrix. Eg a hypothetical (map-values #'round #(1.4 1.7) would return #2A((1 0.4) (2 -0.3)) (errors in floating point arithmetic disregarded). My messy solution currently uses multiple-value-list to capture the returned values as a list, then extract elements from this list, which are copied to rows of a matrix. I wonder if there is something more elegant. Thanks, Tamas On 13 oct, 21:32, Tamas Papp <tkp...@gmail.com> wrote: > Hi, > > Sup...

Varying Offset Values
Hi, I have been observing the values that a stratum 2 server has for its clock offset from multiple stratum 1 GPS based time servers using ntpq -p. Two of the three time servers show an offset agreement in the 50-200 microsecond range. But the offset for third, which is at the same site as one of the first two, has been off as much as 10 milliseconds from the other two but now is down to 800 microseconds. The first two timer servers are installed at different sites and the third is installed on an adjacent subnet to one of the servers in the first group. I am showing a consistent...

Image subtraction values
Dear all, I've been trying to calculate deviation of each image from the mean at pixel by pixel basis. When I checked pixel values, they look to be way high. I've trying to figure it out, but due to my short knowledge of IDL, problem solving doesn't seem to progress. For your better understanding, I would like to show what I wrote. I really appreciate for your comments and advice. ;------------------------------------------------------------------------------------------------- pro deviation file = File_Search('C:\DataProcessing\Images\*.tif', Count=count) ...