calculations between rows solved

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

calculations between rows solved

Paul Mcgeoghan
Figured it out using Data Aggregate,
I can specify the 1st row and the last row and create a new aggregated dataset
from that where I can then compute the difference between the 2 dates.

Hi,

I have a customer with data as follows:
      ID        Date
         1      11-DEC-2001
       1        21-DEC-2001
       1        30-DEC-2001
       2        10-JAN-2000
       2        12-JAN-2000
       2        15-FEB-2000
       2        20-MAR-2000
       2        26-APR-2000

He wants to have:
ID  Days
1   19
2   107

What is best way to do this?
Thanks,
Paul

==================
Paul McGeoghan,
Application support specialist (Statistics and Databases),
University Infrastructure Group (UIG),
Information Services,
Cardiff University.
Tel. 02920 (875035).
Reply | Threaded
Open this post in threaded view
|

Re: calculations between rows solved

Edward Boadi
Paul, I am interested in knowing (syntax) how that
was done.
Regards.
Edward.

-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]]On Behalf Of
Paul Mcgeoghan
Sent: Tuesday, September 12, 2006 6:03 AM
To: [hidden email]
Subject: calculations between rows solved


Figured it out using Data Aggregate,
I can specify the 1st row and the last row and create a new aggregated dataset
from that where I can then compute the difference between the 2 dates.

Hi,

I have a customer with data as follows:
      ID        Date
         1      11-DEC-2001
       1        21-DEC-2001
       1        30-DEC-2001
       2        10-JAN-2000
       2        12-JAN-2000
       2        15-FEB-2000
       2        20-MAR-2000
       2        26-APR-2000

He wants to have:
ID  Days
1   19
2   107

What is best way to do this?
Thanks,
Paul

==================
Paul McGeoghan,
Application support specialist (Statistics and Databases),
University Infrastructure Group (UIG),
Information Services,
Cardiff University.
Tel. 02920 (875035).
Reply | Threaded
Open this post in threaded view
|

Re: calculations between rows solved

Marks, Jim
In reply to this post by Paul Mcgeoghan
Edward

DATA LIST FREE /id  (f8.0) date (date10).
BEGIN DATA
        1      11-12-2001
       1        21-12-2001
       1        30-12-2001
       2        10-1-2000
       2        12-1-2000
       2        15-2-2000
       2        20-3-2000
       2        26-4-2000
END DATA.

AGGREGATE OUTFILE =  * /BREAK id /start = MIN(date) /end = MAX(date).

COMPUTE days = (end - start)/ 86400.
FORMAT days (f8.0).
LIST id days.


--jim

-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of
Edward Boadi
Sent: Tuesday, September 12, 2006 8:10 AM
To: [hidden email]
Subject: Re: calculations between rows solved

Paul, I am interested in knowing (syntax) how that was done.
Regards.
Edward.

-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]]On Behalf Of
Paul Mcgeoghan
Sent: Tuesday, September 12, 2006 6:03 AM
To: [hidden email]
Subject: calculations between rows solved


Figured it out using Data Aggregate,
I can specify the 1st row and the last row and create a new aggregated
dataset from that where I can then compute the difference between the 2
dates.

Hi,

I have a customer with data as follows:
      ID        Date
         1      11-DEC-2001
       1        21-DEC-2001
       1        30-DEC-2001
       2        10-JAN-2000
       2        12-JAN-2000
       2        15-FEB-2000
       2        20-MAR-2000
       2        26-APR-2000

He wants to have:
ID  Days
1   19
2   107

What is best way to do this?
Thanks,
Paul

==================
Paul McGeoghan,
Application support specialist (Statistics and Databases), University
Infrastructure Group (UIG), Information Services, Cardiff University.
Tel. 02920 (875035).
Reply | Threaded
Open this post in threaded view
|

Re: calculations between rows solved

Edward Boadi
In reply to this post by Paul Mcgeoghan
Thanks Jim, you are a STAR !!!!!!!

-----Original Message-----
From: Marks, Jim [mailto:[hidden email]]
Sent: Tuesday, September 12, 2006 10:11 AM
To: Edward Boadi; [hidden email]
Subject: RE: Re: calculations between rows solved


Edward

DATA LIST FREE /id  (f8.0) date (date10).
BEGIN DATA
        1      11-12-2001
       1        21-12-2001
       1        30-12-2001
       2        10-1-2000
       2        12-1-2000
       2        15-2-2000
       2        20-3-2000
       2        26-4-2000
END DATA.

AGGREGATE OUTFILE =  * /BREAK id /start = MIN(date) /end = MAX(date).

COMPUTE days = (end - start)/ 86400.
FORMAT days (f8.0).
LIST id days.


--jim

-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of
Edward Boadi
Sent: Tuesday, September 12, 2006 8:10 AM
To: [hidden email]
Subject: Re: calculations between rows solved

Paul, I am interested in knowing (syntax) how that was done.
Regards.
Edward.

-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]]On Behalf Of
Paul Mcgeoghan
Sent: Tuesday, September 12, 2006 6:03 AM
To: [hidden email]
Subject: calculations between rows solved


Figured it out using Data Aggregate,
I can specify the 1st row and the last row and create a new aggregated
dataset from that where I can then compute the difference between the 2
dates.

Hi,

I have a customer with data as follows:
      ID        Date
         1      11-DEC-2001
       1        21-DEC-2001
       1        30-DEC-2001
       2        10-JAN-2000
       2        12-JAN-2000
       2        15-FEB-2000
       2        20-MAR-2000
       2        26-APR-2000

He wants to have:
ID  Days
1   19
2   107

What is best way to do this?
Thanks,
Paul

==================
Paul McGeoghan,
Application support specialist (Statistics and Databases), University
Infrastructure Group (UIG), Information Services, Cardiff University.
Tel. 02920 (875035).
Reply | Threaded
Open this post in threaded view
|

Re: calculations between rows solved

Beadle, ViAnn
In reply to this post by Marks, Jim
with this data, the days will be slightly off because you don't account for the pesky leap day. Use the datediff function instead.

________________________________

From: SPSSX(r) Discussion on behalf of Marks, Jim
Sent: Tue 9/12/2006 9:10 AM
To: [hidden email]
Subject: Re: calculations between rows solved



Edward

DATA LIST FREE /id  (f8.0) date (date10).
BEGIN DATA
        1      11-12-2001
       1        21-12-2001
       1        30-12-2001
       2        10-1-2000
       2        12-1-2000
       2        15-2-2000
       2        20-3-2000
       2        26-4-2000
END DATA.

AGGREGATE OUTFILE =  * /BREAK id /start = MIN(date) /end = MAX(date).

COMPUTE days = (end - start)/ 86400.
FORMAT days (f8.0).
LIST id days.


--jim

-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of
Edward Boadi
Sent: Tuesday, September 12, 2006 8:10 AM
To: [hidden email]
Subject: Re: calculations between rows solved

Paul, I am interested in knowing (syntax) how that was done.
Regards.
Edward.

-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]]On Behalf Of
Paul Mcgeoghan
Sent: Tuesday, September 12, 2006 6:03 AM
To: [hidden email]
Subject: calculations between rows solved


Figured it out using Data Aggregate,
I can specify the 1st row and the last row and create a new aggregated
dataset from that where I can then compute the difference between the 2
dates.

Hi,

I have a customer with data as follows:
      ID        Date
         1      11-DEC-2001
       1        21-DEC-2001
       1        30-DEC-2001
       2        10-JAN-2000
       2        12-JAN-2000
       2        15-FEB-2000
       2        20-MAR-2000
       2        26-APR-2000

He wants to have:
ID  Days
1   19
2   107

What is best way to do this?
Thanks,
Paul

==================
Paul McGeoghan,
Application support specialist (Statistics and Databases), University
Infrastructure Group (UIG), Information Services, Cardiff University.
Tel. 02920 (875035).
Reply | Threaded
Open this post in threaded view
|

Re: calculations between rows solved

Oliver, Richard
Actually, leap days shouldn't be a problem, although I would also recommend the datediff function or the ctime.days function.

-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Beadle, ViAnn
Sent: Tuesday, September 12, 2006 9:29 AM
To: [hidden email]
Subject: Re: calculations between rows solved

with this data, the days will be slightly off because you don't account for the pesky leap day. Use the datediff function instead.

________________________________

From: SPSSX(r) Discussion on behalf of Marks, Jim
Sent: Tue 9/12/2006 9:10 AM
To: [hidden email]
Subject: Re: calculations between rows solved



Edward

DATA LIST FREE /id  (f8.0) date (date10).
BEGIN DATA
        1      11-12-2001
       1        21-12-2001
       1        30-12-2001
       2        10-1-2000
       2        12-1-2000
       2        15-2-2000
       2        20-3-2000
       2        26-4-2000
END DATA.

AGGREGATE OUTFILE =  * /BREAK id /start = MIN(date) /end = MAX(date).

COMPUTE days = (end - start)/ 86400.
FORMAT days (f8.0).
LIST id days.


--jim

-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Edward Boadi
Sent: Tuesday, September 12, 2006 8:10 AM
To: [hidden email]
Subject: Re: calculations between rows solved

Paul, I am interested in knowing (syntax) how that was done.
Regards.
Edward.

-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]]On Behalf Of Paul Mcgeoghan
Sent: Tuesday, September 12, 2006 6:03 AM
To: [hidden email]
Subject: calculations between rows solved


Figured it out using Data Aggregate,
I can specify the 1st row and the last row and create a new aggregated dataset from that where I can then compute the difference between the 2 dates.

Hi,

I have a customer with data as follows:
      ID        Date
         1      11-DEC-2001
       1        21-DEC-2001
       1        30-DEC-2001
       2        10-JAN-2000
       2        12-JAN-2000
       2        15-FEB-2000
       2        20-MAR-2000
       2        26-APR-2000

He wants to have:
ID  Days
1   19
2   107

What is best way to do this?
Thanks,
Paul

==================
Paul McGeoghan,
Application support specialist (Statistics and Databases), University Infrastructure Group (UIG), Information Services, Cardiff University.
Tel. 02920 (875035).
Reply | Threaded
Open this post in threaded view
|

Re: calculations between rows solved

Paul Mcgeoghan
In reply to this post by Edward Boadi
Edward,

This is the syntax I used:

AGGREGATE
  /OUTFILE='D:/aggr.sav'
  /BREAK=id
  /date_first = FIRST(date) /date_last = LAST(date).

GET
  FILE='D:\aggr.sav'.
DATASET NAME DataSet2 WINDOW=FRONT.

COMPUTE days = DATEDIFF(date_last,date_first,"days") .
EXECUTE .

Paul

==================
Paul McGeoghan,
Application support specialist (Statistics and Databases),
University Infrastructure Group (UIG),
Information Services,
Cardiff University.
Tel. 02920 (875035).

==================
Paul McGeoghan,
Application support specialist (Statistics and Databases),
University Infrastructure Group (UIG),
Information Services,
Cardiff University.
Tel. 02920 (875035).

>>> "Edward Boadi" <[hidden email]> 12/09/2006 14:10 >>>
Paul, I am interested in knowing (syntax) how that
was done.
Regards.
Edward.

-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]]On Behalf Of
Paul Mcgeoghan
Sent: Tuesday, September 12, 2006 6:03 AM
To: [hidden email]
Subject: calculations between rows solved


Figured it out using Data Aggregate,
I can specify the 1st row and the last row and create a new aggregated dataset
from that where I can then compute the difference between the 2 dates.

Hi,

I have a customer with data as follows:
      ID        Date
         1      11-DEC-2001
       1        21-DEC-2001
       1        30-DEC-2001
       2        10-JAN-2000
       2        12-JAN-2000
       2        15-FEB-2000
       2        20-MAR-2000
       2        26-APR-2000

He wants to have:
ID  Days
1   19
2   107

What is best way to do this?
Thanks,
Paul

==================
Paul McGeoghan,
Application support specialist (Statistics and Databases),
University Infrastructure Group (UIG),
Information Services,
Cardiff University.
Tel. 02920 (875035).