Re: problem with Aggregate function - reply

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

Re: problem with Aggregate function - reply

thara vardhan-2

Hi Mathew

Thank you. Yes precisely that is my problem. The aggregate is not wokring despite my presorting the data file.

However if any member on the list would be kind enough to help me with an alternative solution I would be extremely grateful.

While most of the times I have  2 or 3 records with differing dates sometimes I also have 5 or 6 records with differring dates and I need to pick the record with the earliest legal action date to analyse my data.

for example

Erefnum Increfnum legactdate
1234          5678            12-July-2010
1234          5678           10-Feb-2010
1234          5678           19-Aug-2010


I need to pick record 2 - 10 feb 2010.  

looking foward to your reply.

regards
thara  

Thara,
 
If I’m understanding you correctly you’re saying that the following syntax is not really aggregating.
 
DATASET DECLARE true1.
AGGREGATE

 /OUTFILE='true1'

 /BREAK=EventRefNum to IncidentswithLA

 /LegalActDate_min=MIN(LegalActDate).


I have had the experience of an aggregate not aggregating. I found that if I sorted by the break variable(s) first it worked. I started leaving out sort when I learned that it is not essential. Not presorting seems to save on processing time and memory used by the sort. But then sometimes for some reason without the sort the aggregate doesn’t seem to work. No error message, just the same number of lines of data before and after the aggregate.
 
Thanks
Matt

















Thara Vardhan
Senior Statistician
Performance Improvement & Planning
NSW Police
Tel: (02) 8835-8526



_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

The information contained in this email is intended for the named recipient(s) 
only. It may contain private, confidential, copyright or legally privileged 
information.  If you are not the intended recipient or you have received this 
email by mistake, please reply to the author and delete this email immediately. 
You must not copy, print, forward or distribute this email, nor place reliance 
on its contents. This email and any attachment have been virus scanned. However, 
you are requested to conduct a virus scan as well.  No liability is accepted 
for any loss or damage resulting from a computer virus, or resulting from a delay
or defect in transmission of this email or any attached file. This email does not 
constitute a representation by the NSW Police Force unless the author is legally 
entitled to do so.


Reply | Threaded
Open this post in threaded view
|

Re: problem with Aggregate function - reply

Maurice Vergeer
Hi Thara

I assume the date is defined as a string variable? If so, and if your example is an exact copy of your actual data, there seems to be a space preceding the date in record one. I assume SPSS considers a space as less than 10, ergo record 1 is minimum.

I suggest you try to convert date to a date variable. Use the time/date wizard which is the easiest to use in this case.

I hope this helps.

Best wishes,
Maurice
 





On Sun, Mar 27, 2011 at 20:42, Thara Vardhan <[hidden email]> wrote:

Hi Mathew

Thank you. Yes precisely that is my problem. The aggregate is not wokring despite my presorting the data file.

However if any member on the list would be kind enough to help me with an alternative solution I would be extremely grateful.

While most of the times I have  2 or 3 records with differing dates sometimes I also have 5 or 6 records with differring dates and I need to pick the record with the earliest legal action date to analyse my data.

for example

Erefnum Increfnum legactdate
1234          5678            12-July-2010
1234          5678           10-Feb-2010
1234          5678           19-Aug-2010


I need to pick record 2 - 10 feb 2010.  

looking foward to your reply.

regards
thara  

Thara,
 
If I’m understanding you correctly you’re saying that the following syntax is not really aggregating.
 
DATASET DECLARE true1.
AGGREGATE

 /OUTFILE='true1'

 /BREAK=EventRefNum to IncidentswithLA

 /LegalActDate_min=MIN(LegalActDate).


I have had the experience of an aggregate not aggregating. I found that if I sorted by the break variable(s) first it worked. I started leaving out sort when I learned that it is not essential. Not presorting seems to save on processing time and memory used by the sort. But then sometimes for some reason without the sort the aggregate doesn’t seem to work. No error message, just the same number of lines of data before and after the aggregate.
 
Thanks
Matt

















Thara Vardhan
Senior Statistician
Performance Improvement & Planning
NSW Police
Tel: (02) 8835-8526



_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

The information contained in this email is intended for the named recipient(s) 
only. It may contain private, confidential, copyright or legally privileged 
information.  If you are not the intended recipient or you have received this 
email by mistake, please reply to the author and delete this email immediately. 
You must not copy, print, forward or distribute this email, nor place reliance 
on its contents. This email and any attachment have been virus scanned. However, 
you are requested to conduct a virus scan as well.  No liability is accepted 
for any loss or damage resulting from a computer virus, or resulting from a delay
or defect in transmission of this email or any attached file. This email does not 
constitute a representation by the NSW Police Force unless the author is legally 
entitled to do so.





--
___________________________________________________________________
Maurice Vergeer
Department of communication, Radboud University  (www.ru.nl)
PO Box 9104, NL-6500 HE Nijmegen, The Netherlands

Visiting Professor Yeungnam University, Gyeongsan, South Korea

Recent publications:
-Vergeer, M., Hermans, L., & Sams, S. (accepted for publication).
Online social networks and micro-blogging in political campaigning:
The exploration of a new campaign tool and a new campaign style. Party
Politics.
-Eisinga, R., Franses, Ph.H., & Vergeer, M. (2010). Weather conditions
and daily television use in the Netherlands, 1996–2005. International
Journal of Meteorology.

Webspace
www.mauricevergeer.nl
http://blog.mauricevergeer.nl/
www.journalisteninhetdigitaletijdperk.nl
maurice.vergeer (skype)
___________________________________________________________________





Reply | Threaded
Open this post in threaded view
|

Re: problem with Aggregate function - reply to Maurice

thara vardhan-2

Hi Maurice

Thanks for your reply.

No there is no problem with the date variable because in my original data file the legal action date is a date variable. Aggregate mode=add variables works perfectly within the same datafile using the legal action date.

Many thanks

regards
thara



Maurice Vergeer <[hidden email]>
Sent by: [hidden email]

28/03/2011 16:19

To
Thara Vardhan <[hidden email]>
cc
[hidden email]
Subject
Re: problem with Aggregate function - reply





Hi Thara

I assume the date is defined as a string variable? If so, and if your example is an exact copy of your actual data, there seems to be a space preceding the date in record one. I assume SPSS considers a space as less than 10, ergo record 1 is minimum.

I suggest you try to convert date to a date variable. Use the time/date wizard which is the easiest to use in this case.

I hope this helps.

Best wishes,
Maurice
 





On Sun, Mar 27, 2011 at 20:42, Thara Vardhan <
vard1tha@...> wrote:

Hi Mathew


Thank you. Yes precisely that is my problem. The aggregate is not wokring despite my presorting the data file.


However if any member on the list would be kind enough to help me with an alternative solution I would be extremely grateful.


While most of the times I have  2 or 3 records with differing dates sometimes I also have 5 or 6 records with differring dates and I need to pick the record with the earliest legal action date to analyse my data.


for example


Erefnum Increfnum legactdate

1234          5678            12-July-2010

1234          5678           10-Feb-2010

1234          5678           19-Aug-2010



I need to pick record 2 - 10 feb 2010.  


looking foward to your reply.


regards

thara  


Thara,

 

If I’m understanding you correctly you’re saying that the following syntax is not really aggregating.

 

DATASET DECLARE true1.

AGGREGATE

 /OUTFILE='true1'

 /BREAK=EventRefNum to IncidentswithLA

 /LegalActDate_min=MIN(LegalActDate).


I have had the experience of an aggregate not aggregating. I found that if I sorted by the break variable(s) first it worked. I started leaving out sort when I learned that it is not essential. Not presorting seems to save on processing time and memory used by the sort. But then sometimes for some reason without the sort the aggregate doesn’t seem to work. No error message, just the same number of lines of data before and after the aggregate.

 

Thanks

Matt



















_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

The information contained in this email is intended for the named recipient(s) 
only. It may contain private, confidential, copyright or legally privileged 
information.  If you are not the intended recipient or you have received this 
email by mistake, please reply to the author and delete this email immediately. 
You must not copy, print, forward or distribute this email, nor place reliance 
on its contents. This email and any attachment have been virus scanned. However, 
you are requested to conduct a virus scan as well.  No liability is accepted 
for any loss or damage resulting from a computer virus, or resulting from a delay
or defect in transmission of this email or any attached file. This email does not 
constitute a representation by the NSW Police Force unless the author is legally 
entitled to do so.





--
___________________________________________________________________
Maurice Vergeer
Department of communication, Radboud University  (
www.ru.nl)
PO Box 9104, NL-6500 HE Nijmegen, The Netherlands

Visiting Professor Yeungnam University, Gyeongsan, South Korea

Recent publications:
-Vergeer, M., Hermans, L., & Sams, S. (accepted for publication).
Online social networks and micro-blogging in political campaigning:
The exploration of a new campaign tool and a new campaign style. Party
Politics.
-Eisinga, R., Franses, Ph.H., & Vergeer, M. (2010). Weather conditions
and daily television use in the Netherlands, 1996–2005. International
Journal of Meteorology.

Webspace

www.mauricevergeer.nl
http://blog.mauricevergeer.nl/
www.journalisteninhetdigitaletijdperk.nl
maurice.vergeer (skype)
___________________________________________________________________







_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

All mail is subject to content scanning for possible violation of NSW Police Force
Electronic Messaging Policy. All NSW Police Force employees are required to
familiarise themselves with the content of the policy, found under Policies on the
NSW Police Force Intranet.







_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

The information contained in this email is intended for the named recipient(s) 
only. It may contain private, confidential, copyright or legally privileged 
information.  If you are not the intended recipient or you have received this 
email by mistake, please reply to the author and delete this email immediately. 
You must not copy, print, forward or distribute this email, nor place reliance 
on its contents. This email and any attachment have been virus scanned. However, 
you are requested to conduct a virus scan as well.  No liability is accepted 
for any loss or damage resulting from a computer virus, or resulting from a delay
or defect in transmission of this email or any attached file. This email does not 
constitute a representation by the NSW Police Force unless the author is legally 
entitled to do so.


Reply | Threaded
Open this post in threaded view
|

Re: problem with Aggregate function - reply to Maurice

Maurice Vergeer
Dear Thara

re-reading some of your posts, you state this: "My original datafile contains 2255 records where two or more records have the same  eventrefnum and incidentrefnum but with differing legalactdate. I need to pick the records with the earliest legalactdate ".

I suggest you try the following:


sort cases  by
eventrefnum  incidentrefnum  legalactdate.
compute id=$casenum.
select if id=1 or eventrefnum ne lag(eventrefnum).

the first line sorts the cases. Within each eventrefnum the data are sorted as well.
The second line is instrumental to identify the first record,
because the third line compares a record the prior one (the first record doesn't have a prior record).
the second part identifies those record that are new events with the earliest dates.

I hope this works.

Maurice




On Sun, Mar 27, 2011 at 21:25, Thara Vardhan <[hidden email]> wrote:

Hi Maurice

Thanks for your reply.

No there is no problem with the date variable because in my original data file the legal action date is a date variable. Aggregate mode=add variables works perfectly within the same datafile using the legal action date.

Many thanks

regards
thara



Maurice Vergeer <[hidden email]>
Sent by: [hidden email]

28/03/2011 16:19

To
Thara Vardhan <[hidden email]>
cc
[hidden email]
Subject
Re: problem with Aggregate function - reply





Hi Thara

I assume the date is defined as a string variable? If so, and if your example is an exact copy of your actual data, there seems to be a space preceding the date in record one. I assume SPSS considers a space as less than 10, ergo record 1 is minimum.

I suggest you try to convert date to a date variable. Use the time/date wizard which is the easiest to use in this case.

I hope this helps.

Best wishes,
Maurice
 





On Sun, Mar 27, 2011 at 20:42, Thara Vardhan <
[hidden email]> wrote:

Hi Mathew


Thank you. Yes precisely that is my problem. The aggregate is not wokring despite my presorting the data file.


However if any member on the list would be kind enough to help me with an alternative solution I would be extremely grateful.


While most of the times I have  2 or 3 records with differing dates sometimes I also have 5 or 6 records with differring dates and I need to pick the record with the earliest legal action date to analyse my data.


for example


Erefnum Increfnum legactdate

1234          5678            12-July-2010

1234          5678           10-Feb-2010

1234          5678           19-Aug-2010



I need to pick record 2 - 10 feb 2010.  


looking foward to your reply.


regards

thara  


Thara,

 

If I’m understanding you correctly you’re saying that the following syntax is not really aggregating.

 

DATASET DECLARE true1.

AGGREGATE

 /OUTFILE='true1'

 /BREAK=EventRefNum to IncidentswithLA

 /LegalActDate_min=MIN(LegalActDate).


I have had the experience of an aggregate not aggregating. I found that if I sorted by the break variable(s) first it worked. I started leaving out sort when I learned that it is not essential. Not presorting seems to save on processing time and memory used by the sort. But then sometimes for some reason without the sort the aggregate doesn’t seem to work. No error message, just the same number of lines of data before and after the aggregate.

 

Thanks

Matt



















_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

The information contained in this email is intended for the named recipient(s) 
only. It may contain private, confidential, copyright or legally privileged 
information.  If you are not the intended recipient or you have received this 
email by mistake, please reply to the author and delete this email immediately. 
You must not copy, print, forward or distribute this email, nor place reliance 
on its contents. This email and any attachment have been virus scanned. However, 
you are requested to conduct a virus scan as well.  No liability is accepted 
for any loss or damage resulting from a computer virus, or resulting from a delay
or defect in transmission of this email or any attached file. This email does not 
constitute a representation by the NSW Police Force unless the author is legally 
entitled to do so.





--
___________________________________________________________________
Maurice Vergeer
Department of communication, Radboud University  (
www.ru.nl)
PO Box 9104, NL-6500 HE Nijmegen, The Netherlands

Visiting Professor Yeungnam University, Gyeongsan, South Korea

Recent publications:
-Vergeer, M., Hermans, L., & Sams, S. (accepted for publication).
Online social networks and micro-blogging in political campaigning:
The exploration of a new campaign tool and a new campaign style. Party
Politics.
-Eisinga, R., Franses, Ph.H., & Vergeer, M. (2010). Weather conditions
and daily television use in the Netherlands, 1996–2005. International
Journal of Meteorology.

Webspace

www.mauricevergeer.nl
http://blog.mauricevergeer.nl/
www.journalisteninhetdigitaletijdperk.nl
maurice.vergeer (skype)
___________________________________________________________________







_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

All mail is subject to content scanning for possible violation of NSW Police Force
Electronic Messaging Policy. All NSW Police Force employees are required to
familiarise themselves with the content of the policy, found under Policies on the
NSW Police Force Intranet.







_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

The information contained in this email is intended for the named recipient(s) 
only. It may contain private, confidential, copyright or legally privileged 
information.  If you are not the intended recipient or you have received this 
email by mistake, please reply to the author and delete this email immediately. 
You must not copy, print, forward or distribute this email, nor place reliance 
on its contents. This email and any attachment have been virus scanned. However, 
you are requested to conduct a virus scan as well.  No liability is accepted 
for any loss or damage resulting from a computer virus, or resulting from a delay
or defect in transmission of this email or any attached file. This email does not 
constitute a representation by the NSW Police Force unless the author is legally 
entitled to do so.





--
___________________________________________________________________
Maurice Vergeer
Department of communication, Radboud University  (www.ru.nl)
PO Box 9104, NL-6500 HE Nijmegen, The Netherlands

Visiting Professor Yeungnam University, Gyeongsan, South Korea

Recent publications:
-Vergeer, M., Hermans, L., & Sams, S. (accepted for publication).
Online social networks and micro-blogging in political campaigning:
The exploration of a new campaign tool and a new campaign style. Party
Politics.
-Eisinga, R., Franses, Ph.H., & Vergeer, M. (2010). Weather conditions
and daily television use in the Netherlands, 1996–2005. International
Journal of Meteorology.

Webspace
www.mauricevergeer.nl
http://blog.mauricevergeer.nl/
www.journalisteninhetdigitaletijdperk.nl
maurice.vergeer (skype)
___________________________________________________________________





Reply | Threaded
Open this post in threaded view
|

Re: problem with Aggregate function - reply

Garry Gelade
In reply to this post by thara vardhan-2

Dear Thara

 

Use the aggregate command to add a new variable to your datafile called mindate. The (unchecked) syntax would be something like:

 

AGGREGATE
 /OUTFILE=*
 /BREAK=
Erefnum Increfnum

/MODE=ADDVARIABLES
/mindate=MIN(LegalActDate).

 

You will retain all cases, and the cases you want are those for which legalactdate =mindate.

 

Garry Gelade

Business Analytic Ltd.

 

From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Thara Vardhan
Sent: 28 March 2011 05:42
To: [hidden email]
Subject: Re: problem with Aggregate function - reply

 


Hi Mathew

Thank you. Yes precisely that is my problem. The aggregate is not wokring despite my presorting the data file.

However if any member on the list would be kind enough to help me with an alternative solution I would be extremely grateful.

While most of the times I have  2 or 3 records with differing dates sometimes I also have 5 or 6 records with differring dates and I need to pick the record with the earliest legal action date to analyse my data.

for example

Erefnum Increfnum legactdate
1234          5678            12-July-2010
1234          5678           10-Feb-2010
1234          5678           19-Aug-2010


I need to pick record 2 - 10 feb 2010.  

looking foward to your reply.

regards
thara  

Thara,
 
If I’m understanding you correctly you’re saying that the following syntax is not really aggregating.
 
DATASET DECLARE true1.
AGGREGATE

 /OUTFILE='true1'

 /BREAK=EventRefNum to IncidentswithLA

 /LegalActDate_min=MIN(LegalActDate).


I have had the experience of an aggregate not aggregating. I found that if I sorted by the break variable(s) first it worked. I started leaving out sort when I learned that it is not essential. Not presorting seems to save on processing time and memory used by the sort. But then sometimes for some reason without the sort the aggregate doesn’t seem to work. No error message, just the same number of lines of data before and after the aggregate.
 
Thanks
Matt

















Thara Vardhan
Senior Statistician
Performance Improvement & Planning
NSW Police
Tel: (02) 8835-8526


_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

The information contained in this email is intended for the named recipient(s) 
only. It may contain private, confidential, copyright or legally privileged 
information.  If you are not the intended recipient or you have received this 
email by mistake, please reply to the author and delete this email immediately. 
You must not copy, print, forward or distribute this email, nor place reliance 
on its contents. This email and any attachment have been virus scanned. However, 
you are requested to conduct a virus scan as well.  No liability is accepted 
for any loss or damage resulting from a computer virus, or resulting from a delay
or defect in transmission of this email or any attached file. This email does not 
constitute a representation by the NSW Police Force unless the author is legally 
entitled to do so.

 

Reply | Threaded
Open this post in threaded view
|

Re: problem with Aggregate function - reply to Maurice

ariel barak
In reply to this post by Maurice Vergeer
Hi Thara and Maurice,

I think this is a perfect problem for using the Identify Duplicates Wizard, found by clicking Data>Identify Duplicate Cases. If I'm understanding the issue correctly, you want to define sets of cases as duplicates if they have the same eventrefnum and incidentrefnum and select the record with the earliest legalactdate.

So in the wizard, you'd want to select eventrefnum and incidentrefnum for the box in the top right labeled "Define matching cases by:" and then select legalactdate for the box below it labeled "Sort within matching groups by:"

If you sort the legalactdate in descending order, then you will want to select the "Last case in each group is Primary" radio button. If you select legalactdate in ascending order, which I did with the syntax below, you will want to select "First Case in group is Primary" radio button. The records you want to keep, will be marked as 1 and those that you want to remove from consideration will be marked as duplicates with a 0.

The wizard creates a lot of syntax, but it works wonderfully and is intuitive (for me!). If you run the select command, the records will be permanently dropped, so be sure to work off a file that you have a copy of. Copy and Paste the syntax below into your syntax editor and see what happens after you run lines 1-34 of the code below.

Hope this helps,
Ariel

DATA LIST LIST /Erefnum (F8.0) Increfnum (F8.0) legactdate (DATE11).
BEGIN DATA
1234 5678 12-July-2010
1234 5678 10-Feb-2010
1234 5678 19-Aug-2010
142 233 12-Dec-2009
163 999 3-Sep-2008
163 999 18-Sep-2008
END DATA.

* Identify Duplicate Cases.
SORT CASES BY Erefnum(A) Increfnum(A) legactdate(A).
MATCH FILES
  /FILE=*
  /BY Erefnum Increfnum
  /FIRST=PrimaryFirst
  /LAST=PrimaryLast.
DO IF (PrimaryFirst).
COMPUTE  MatchSequence=1-PrimaryLast.
ELSE.
COMPUTE  MatchSequence=MatchSequence+1.
END IF.
LEAVE  MatchSequence.
FORMATS  MatchSequence (f7).
COMPUTE  InDupGrp=MatchSequence>0.
SORT CASES InDupGrp(D).
MATCH FILES
  /FILE=*
  /DROP=PrimaryLast InDupGrp MatchSequence.
VARIABLE LABELS  PrimaryFirst 'Indicator of each first matching case as Primary'.
VALUE LABELS  PrimaryFirst 0 'Duplicate Case' 1 'Primary Case'.
VARIABLE LEVEL  PrimaryFirst (ORDINAL).
FREQUENCIES VARIABLES=PrimaryFirst.
EXECUTE.

* Look at the Data Window before running the SELECT IF command below.

SELECT IF PrimaryFirst=1.
EXECUTE.

LIST.

On Mon, Mar 28, 2011 at 12:45 AM, Maurice Vergeer <[hidden email]> wrote:
Dear Thara

re-reading some of your posts, you state this: "My original datafile contains 2255 records where two or more records have the same  eventrefnum and incidentrefnum but with differing legalactdate. I need to pick the records with the earliest legalactdate ".

I suggest you try the following:


sort cases  by
eventrefnum  incidentrefnum  legalactdate.
compute id=$casenum.
select if id=1 or eventrefnum ne lag(eventrefnum).

the first line sorts the cases. Within each eventrefnum the data are sorted as well.
The second line is instrumental to identify the first record,
because the third line compares a record the prior one (the first record doesn't have a prior record).
the second part identifies those record that are new events with the earliest dates.

I hope this works.

Maurice





On Sun, Mar 27, 2011 at 21:25, Thara Vardhan <[hidden email]> wrote:

Hi Maurice

Thanks for your reply.

No there is no problem with the date variable because in my original data file the legal action date is a date variable. Aggregate mode=add variables works perfectly within the same datafile using the legal action date.

Many thanks

regards
thara



Maurice Vergeer <[hidden email]>
Sent by: [hidden email]

28/03/2011 16:19

To
Thara Vardhan <[hidden email]>
cc
[hidden email]
Subject
Re: problem with Aggregate function - reply





Hi Thara

I assume the date is defined as a string variable? If so, and if your example is an exact copy of your actual data, there seems to be a space preceding the date in record one. I assume SPSS considers a space as less than 10, ergo record 1 is minimum.

I suggest you try to convert date to a date variable. Use the time/date wizard which is the easiest to use in this case.

I hope this helps.

Best wishes,
Maurice
 





On Sun, Mar 27, 2011 at 20:42, Thara Vardhan <
[hidden email]> wrote:

Hi Mathew


Thank you. Yes precisely that is my problem. The aggregate is not wokring despite my presorting the data file.


However if any member on the list would be kind enough to help me with an alternative solution I would be extremely grateful.


While most of the times I have  2 or 3 records with differing dates sometimes I also have 5 or 6 records with differring dates and I need to pick the record with the earliest legal action date to analyse my data.


for example


Erefnum Increfnum legactdate

1234          5678            12-July-2010

1234          5678           10-Feb-2010

1234          5678           19-Aug-2010



I need to pick record 2 - 10 feb 2010.  


looking foward to your reply.


regards

thara  


Thara,

 

If I’m understanding you correctly you’re saying that the following syntax is not really aggregating.

 

DATASET DECLARE true1.

AGGREGATE

 /OUTFILE='true1'

 /BREAK=EventRefNum to IncidentswithLA

 /LegalActDate_min=MIN(LegalActDate).


I have had the experience of an aggregate not aggregating. I found that if I sorted by the break variable(s) first it worked. I started leaving out sort when I learned that it is not essential. Not presorting seems to save on processing time and memory used by the sort. But then sometimes for some reason without the sort the aggregate doesn’t seem to work. No error message, just the same number of lines of data before and after the aggregate.

 

Thanks

Matt



















_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

The information contained in this email is intended for the named recipient(s) 
only. It may contain private, confidential, copyright or legally privileged 
information.  If you are not the intended recipient or you have received this 
email by mistake, please reply to the author and delete this email immediately. 
You must not copy, print, forward or distribute this email, nor place reliance 
on its contents. This email and any attachment have been virus scanned. However, 
you are requested to conduct a virus scan as well.  No liability is accepted 
for any loss or damage resulting from a computer virus, or resulting from a delay
or defect in transmission of this email or any attached file. This email does not 
constitute a representation by the NSW Police Force unless the author is legally 
entitled to do so.





--
___________________________________________________________________
Maurice Vergeer
Department of communication, Radboud University  (
www.ru.nl)
PO Box 9104, NL-6500 HE Nijmegen, The Netherlands

Visiting Professor Yeungnam University, Gyeongsan, South Korea

Recent publications:
-Vergeer, M., Hermans, L., & Sams, S. (accepted for publication).
Online social networks and micro-blogging in political campaigning:
The exploration of a new campaign tool and a new campaign style. Party
Politics.
-Eisinga, R., Franses, Ph.H., & Vergeer, M. (2010). Weather conditions
and daily television use in the Netherlands, 1996–2005. International
Journal of Meteorology.

Webspace

www.mauricevergeer.nl
http://blog.mauricevergeer.nl/
www.journalisteninhetdigitaletijdperk.nl
maurice.vergeer (skype)
___________________________________________________________________







_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

All mail is subject to content scanning for possible violation of NSW Police Force
Electronic Messaging Policy. All NSW Police Force employees are required to
familiarise themselves with the content of the policy, found under Policies on the
NSW Police Force Intranet.







_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

The information contained in this email is intended for the named recipient(s) 
only. It may contain private, confidential, copyright or legally privileged 
information.  If you are not the intended recipient or you have received this 
email by mistake, please reply to the author and delete this email immediately. 
You must not copy, print, forward or distribute this email, nor place reliance 
on its contents. This email and any attachment have been virus scanned. However, 
you are requested to conduct a virus scan as well.  No liability is accepted 
for any loss or damage resulting from a computer virus, or resulting from a delay
or defect in transmission of this email or any attached file. This email does not 
constitute a representation by the NSW Police Force unless the author is legally 
entitled to do so.





--
___________________________________________________________________
Maurice Vergeer
Department of communication, Radboud University  (www.ru.nl)
PO Box 9104, NL-6500 HE Nijmegen, The Netherlands

Visiting Professor Yeungnam University, Gyeongsan, South Korea

Recent publications:
-Vergeer, M., Hermans, L., & Sams, S. (accepted for publication).
Online social networks and micro-blogging in political campaigning:
The exploration of a new campaign tool and a new campaign style. Party
Politics.
-Eisinga, R., Franses, Ph.H., & Vergeer, M. (2010). Weather conditions
and daily television use in the Netherlands, 1996–2005. International
Journal of Meteorology.

Webspace
www.mauricevergeer.nl
http://blog.mauricevergeer.nl/
www.journalisteninhetdigitaletijdperk.nl
maurice.vergeer (skype)
___________________________________________________________________






Reply | Threaded
Open this post in threaded view
|

Re: problem with Aggregate function - reply to Maurice

Bruce Weaver
Administrator
In reply to this post by Maurice Vergeer
I don't think Thara has provided enough info about the nature of the data file for us to know if Maurice's solution will work as desired or not.  If there can be multiple values of Increfnum for a given Erefnum, it will fail.  E.g.,

data list list / Erefnum Increfnum (2f5.0) legactdate(date11).
begin data
1234          5678            12-July-2010
 142           233           12-Dec-2009
1234          5678           10-Feb-2010
1234          5678           19-Aug-2010
 163           999            3-Sep-2008
1234          5679            12-July-2010
 163           999           18-Sep-2008
1234          5679           10-Feb-2010
1234          5679           19-Aug-2010
end data.

list.
sort cases  by Erefnum  Increfnum  legactdate.
compute case=$casenum.
select if case=1 or Erefnum ne lag(Erefnum).
list.
* PROBLEM:  No record for the 1234 x 5679 combination.


Garry's AGGREGATE (with a small repair to the placement of ADDVARIABLES) would work with this dataset though.

AGGREGATE
  /OUTFILE=* MODE=ADDVARIABLES
  /BREAK=Erefnum Increfnum
  /mindate=MIN(legactdate).

list.
select if legactdate EQ mindate.
list.


Using MATCH FILES to flag the earliest record within each unique combination of Erefnum and Increfnum would work too--this is the method at the core of the Identify-Duplicate-Cases method posted by Ariel.  But it requires a SORT, which the AGGREGATE method does not.

* Match Files method at heart of Find-Duplicate-Records.
sort cases  by Erefnum  Increfnum  legactdate.
match files file = * / by Erefnum  Increfnum / first = earliest.
select if earliest.
list.

HTH.


Maurice Vergeer wrote
Dear Thara

re-reading some of your posts, you state this: "My original datafile
contains 2255 records where two or more records have the same  eventrefnum
and incidentrefnum but with differing legalactdate. I need to pick the
records with the earliest legalactdate ".

I suggest you try the following:


sort cases  by eventrefnum  incidentrefnum  legalactdate.
compute id=$casenum.
select if id=1 or eventrefnum ne lag(eventrefnum).

the first line sorts the cases. Within each eventrefnum the data are sorted
as well.
The second line is instrumental to identify the first record,
because the third line compares a record the prior one (the first record
doesn't have a prior record).
the second part identifies those record that are new events with the
earliest dates.

I hope this works.

Maurice




On Sun, Mar 27, 2011 at 21:25, Thara Vardhan <vard1tha@police.nsw.gov.au>wrote:

>
> Hi Maurice
>
> Thanks for your reply.
>
> No there is no problem with the date variable because in my original data
> file the legal action date is a date variable. Aggregate mode=add variables
> works perfectly within the same datafile using the legal action date.
>
> Many thanks
>
> regards
> thara
>
>
>
>  *Maurice Vergeer <m.vergeer@maw.ru.nl>*
> Sent by: maurice.vergeer@gmail.com
>
> 28/03/2011 16:19
>   To
> Thara Vardhan <vard1tha@police.nsw.gov.au>
> cc
> SPSSX-L@listserv.uga.edu
> Subject
> Re: problem with Aggregate function - reply
>
>
>
>
> Hi Thara
>
> I assume the date is defined as a string variable? If so, and if your
> example is an exact copy of your actual data, there seems to be a space
> preceding the date in record one. I assume SPSS considers a space as less
> than 10, ergo record 1 is minimum.
>
> I suggest you try to convert date to a date variable. Use the time/date
> wizard which is the easiest to use in this case.
>
> I hope this helps.
>
> Best wishes,
> Maurice
>
>
>
>
>
>
> On Sun, Mar 27, 2011 at 20:42, Thara Vardhan <*vard1tha@police.nsw.gov.au*<vard1tha@police.nsw.gov.au>>
> wrote:
>
> Hi Mathew
>
> Thank you. Yes precisely that is my problem. The aggregate is not wokring
> despite my presorting the data file.
>
> However if any member on the list would be kind enough to help me with an
> alternative solution I would be extremely grateful.
>
> While most of the times I have  2 or 3 records with differing dates
> sometimes I also have 5 or 6 records with differring dates and I need to
> pick the record with the earliest legal action date to analyse my data.
>
> for example
>
> Erefnum Increfnum legactdate
> 1234          5678            12-July-2010
> 1234          5678           10-Feb-2010
> 1234          5678           19-Aug-2010
>
>
> I need to pick record 2 - 10 feb 2010.
>
> looking foward to your reply.
>
> regards
> thara
>
> Thara,
>
> If I’m understanding you correctly you’re saying that the following syntax
> is not really aggregating.
>
> DATASET DECLARE true1.
> AGGREGATE
>  /OUTFILE='true1'
>  /BREAK=EventRefNum to IncidentswithLA
>  /LegalActDate_min=MIN(LegalActDate).
>
> I have had the experience of an aggregate not aggregating. I found that if
> I sorted by the break variable(s) first it worked. I started leaving out
> sort when I learned that it is not essential. Not presorting seems to save
> on processing time and memory used by the sort. But then sometimes for some
> reason without the sort the aggregate doesn’t seem to work. No error
> message, just the same number of lines of data before and after the
> aggregate.
>
> Thanks
> Matt
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
>
>
> The information contained in this email is intended for the named recipient(s)
>
> only. It may contain private, confidential, copyright or legally privileged
>
> information.  If you are not the intended recipient or you have received this
>
> email by mistake, please reply to the author and delete this email immediately.
>
> You must not copy, print, forward or distribute this email, nor place reliance
>
> on its contents. This email and any attachment have been virus scanned. However,
>
> you are requested to conduct a virus scan as well.  No liability is accepted
>
> for any loss or damage resulting from a computer virus, or resulting from a delay
>
> or defect in transmission of this email or any attached file. This email does not
>
> constitute a representation by the NSW Police Force unless the author is legally
> entitled to do so.
>
>
>
>
>
> --
> ___________________________________________________________________
> Maurice Vergeer
> Department of communication, Radboud University  (*www.ru.nl*<http://www.ru.nl/>
> )
> PO Box 9104, NL-6500 HE Nijmegen, The Netherlands
>
> Visiting Professor Yeungnam University, Gyeongsan, South Korea
>
> Recent publications:
> -Vergeer, M., Hermans, L., & Sams, S. (accepted for publication).
> Online social networks and micro-blogging in political campaigning:
> The exploration of a new campaign tool and a new campaign style. Party
> Politics.
> -Eisinga, R., Franses, Ph.H., & Vergeer, M. (2010). Weather conditions
> and daily television use in the Netherlands, 1996–2005. International
> Journal of Meteorology.
>
> Webspace*
> **www.mauricevergeer.nl* <http://www.mauricevergeer.nl/>*
> **http://blog.mauricevergeer.nl/* <http://blog.mauricevergeer.nl/>*
> **www.journalisteninhetdigitaletijdperk.nl*<http://www.journalisteninhetdigitaletijdperk.nl/>
> maurice.vergeer (skype)
> ___________________________________________________________________
>
>
>
>
>
>
>
> _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
> _ _ _ _
>
> All mail is subject to content scanning for possible violation of NSW
> Police Force
> Electronic Messaging Policy. All NSW Police Force employees are required to
> familiarise themselves with the content of the policy, found under Policies
> on the
> NSW Police Force Intranet.
>
>
>
>
>
>
>
>
> _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
>
>
> The information contained in this email is intended for the named recipient(s)
>
> only. It may contain private, confidential, copyright or legally privileged
>
> information.  If you are not the intended recipient or you have received this
>
> email by mistake, please reply to the author and delete this email immediately.
>
> You must not copy, print, forward or distribute this email, nor place reliance
>
> on its contents. This email and any attachment have been virus scanned. However,
>
> you are requested to conduct a virus scan as well.  No liability is accepted
>
> for any loss or damage resulting from a computer virus, or resulting from a delay
>
> or defect in transmission of this email or any attached file. This email does not
>
> constitute a representation by the NSW Police Force unless the author is legally
> entitled to do so.
>
>
>


--
___________________________________________________________________
Maurice Vergeer
Department of communication, Radboud University  (www.ru.nl)
PO Box 9104, NL-6500 HE Nijmegen, The Netherlands

Visiting Professor Yeungnam University, Gyeongsan, South Korea

Recent publications:
-Vergeer, M., Hermans, L., & Sams, S. (accepted for publication).
Online social networks and micro-blogging in political campaigning:
The exploration of a new campaign tool and a new campaign style. Party
Politics.
-Eisinga, R., Franses, Ph.H., & Vergeer, M. (2010). Weather conditions
and daily television use in the Netherlands, 1996–2005. International
Journal of Meteorology.

Webspace
www.mauricevergeer.nl
http://blog.mauricevergeer.nl/
www.journalisteninhetdigitaletijdperk.nl
maurice.vergeer (skype)
___________________________________________________________________
--
Bruce Weaver
bweaver@lakeheadu.ca
http://sites.google.com/a/lakeheadu.ca/bweaver/

"When all else fails, RTFM."

PLEASE NOTE THE FOLLOWING: 
1. My Hotmail account is not monitored regularly. To send me an e-mail, please use the address shown above.
2. The SPSSX Discussion forum on Nabble is no longer linked to the SPSSX-L listserv administered by UGA (https://listserv.uga.edu/).
Reply | Threaded
Open this post in threaded view
|

Re: problem with Aggregate function - reply to Maurice

Maurice Vergeer
this slightly adapted version however does work.
Also I created an ID varable to identify the records you'd be searching for.

data list list / Erefnum Increfnum (2f5.0) legactdate(date11).
begin data
1234          5678            12-July-2010
 142           233           12-Dec-2009
1234          5678           10-Feb-2010
1234          5678           19-Aug-2010
 163           999            3-Sep-2008
1234          5679            12-July-2010
 163           999           18-Sep-2008
1234          5679           10-Feb-2010
1234          5679           19-Aug-2010
end data.

list.
sort cases  by Erefnum  Increfnum  legactdate.
compute case=$casenum.
compute id=0.
if case=1 or (Erefnum ne lag(Erefnum) or increfnum ne lag(increfnum)) id=1.
list.

HTH



On Tue, Mar 29, 2011 at 06:48, Bruce Weaver <[hidden email]> wrote:

> I don't think Thara has provided enough info about the nature of the data
> file for us to know if Maurice's solution will work as desired or not. � If
> there can be multiple values of Increfnum for a given Erefnum, it will fail.
> E.g.,
>
> data list list / Erefnum Increfnum (2f5.0) legactdate(date11).
> begin data
> 1234 �  �  �  �  � 5678 �  �  �  �  �  � 12-July-2010
> � 142 �  �  �  �  �  233 �  �  �  �  �  12-Dec-2009
> 1234 �  �  �  �  � 5678 �  �  �  �  �  10-Feb-2010
> 1234 �  �  �  �  � 5678 �  �  �  �  �  19-Aug-2010
> � 163 �  �  �  �  �  999 �  �  �  �  �  � 3-Sep-2008
> 1234 �  �  �  �  � 5679 �  �  �  �  �  � 12-July-2010
> � 163 �  �  �  �  �  999 �  �  �  �  �  18-Sep-2008
> 1234 �  �  �  �  � 5679 �  �  �  �  �  10-Feb-2010
> 1234 �  �  �  �  � 5679 �  �  �  �  �  19-Aug-2010
> end data.
>
> list.
> sort cases � by Erefnum � Increfnum � legactdate.
> compute case=$casenum.
> select if case=1 or Erefnum ne lag(Erefnum).
> list.
> * PROBLEM: � No record for the 1234 x 5679 combination.
>
>
> Garry's AGGREGATE (with a small repair to the placement of ADDVARIABLES)
> would work with this dataset though.
>
> AGGREGATE
> � /OUTFILE=* MODE=ADDVARIABLES
> � /BREAK=Erefnum Increfnum
> � /mindate=MIN(legactdate).
>
> list.
> select if legactdate EQ mindate.
> list.
>
>
> Using MATCH FILES to flag the earliest record within each unique combination
> of Erefnum and Increfnum would work too--this is the method at the core of
> the Identify-Duplicate-Cases method posted by Ariel. � But it requires a
> SORT, which the AGGREGATE method does not.
>
> * Match Files method at heart of Find-Duplicate-Records.
> sort cases � by Erefnum � Increfnum � legactdate.
> match files file = * / by Erefnum � Increfnum / first = earliest.
> select if earliest.
> list.
>
> HTH.
>
>
>
> Maurice Vergeer wrote:
>>
>> Dear Thara
>>
>> re-reading some of your posts, you state this: "My original datafile
>> contains 2255 records where two or more records have the same � eventrefnum
>> and incidentrefnum but with differing legalactdate. I need to pick the
>> records with the earliest legalactdate ".
>>
>> I suggest you try the following:
>>
>>
>> sort cases � by eventrefnum � incidentrefnum � legalactdate.
>> compute id=$casenum.
>> select if id=1 or eventrefnum ne lag(eventrefnum).
>>
>> the first line sorts the cases. Within each eventrefnum the data are
>> sorted
>> as well.
>> The second line is instrumental to identify the first record,
>> because the third line compares a record the prior one (the first record
>> doesn't have a prior record).
>> the second part identifies those record that are new events with the
>> earliest dates.
>>
>> I hope this works.
>>
>> Maurice
>>
>>
>>
>>
>> On Sun, Mar 27, 2011 at 21:25, Thara Vardhan
>> <[hidden email]>wrote:
>>
>> >
>> > Hi Maurice
>> >
>> > Thanks for your reply.
>> >
>> > No there is no problem with the date variable because in my original
>> data
>> > file the legal action date is a date variable. Aggregate mode=add
>> variables
>> > works perfectly within the same datafile using the legal action date.
>> >
>> > Many thanks
>> >
>> > regards
>> > thara
>> >
>> >
>> >
>> > � *Maurice Vergeer <[hidden email]>*
>> > Sent by: [hidden email]
>> >
>> > 28/03/2011 16:19
>> > �  To
>> > Thara Vardhan <[hidden email]>
>> > cc
>> > [hidden email]
>> > Subject
>> > Re: problem with Aggregate function - reply
>> >
>> >
>> >
>> >
>> > Hi Thara
>> >
>> > I assume the date is defined as a string variable? If so, and if your
>> > example is an exact copy of your actual data, there seems to be a
>> space
>> > preceding the date in record one. I assume SPSS considers a space as
>> less
>> > than 10, ergo record 1 is minimum.
>> >
>> > I suggest you try to convert date to a date variable. Use the
>> time/date
>> > wizard which is the easiest to use in this case.
>> >
>> > I hope this helps.
>> >
>> > Best wishes,
>> > Maurice
>> >
>> >
>> >
>> >
>> >
>> >
>> > On Sun, Mar 27, 2011 at 20:42, Thara Vardhan
>> <*[hidden email]*<[hidden email]>>
>> > wrote:
>> >
>> > Hi Mathew
>> >
>> > Thank you. Yes precisely that is my problem. The aggregate is not
>> wokring
>> > despite my presorting the data file.
>> >
>> > However if any member on the list would be kind enough to help me
>> with an
>> > alternative solution I would be extremely grateful.
>> >
>> > While most of the times I have � 2 or 3 records with differing dates
>> > sometimes I also have 5 or 6 records with differring dates and I need
>> to
>> > pick the record with the earliest legal action date to analyse my
>> data.
>> >
>> > for example
>> >
>> > Erefnum Increfnum legactdate
>> > 1234 �  �  �  �  � 5678 �  �  �  �  �  � 12-July-2010
>> > 1234 �  �  �  �  � 5678 �  �  �  �  �  10-Feb-2010
>> > 1234 �  �  �  �  � 5678 �  �  �  �  �  19-Aug-2010
>> >
>> >
>> > I need to pick record 2 - 10 feb 2010.
>> >
>> > looking foward to your reply.
>> >
>> > regards
>> > thara
>> >
>> > Thara,
>> >
>> > If I’m understanding you correctly you’re saying that the following
>> syntax
>> > is not really aggregating.
>> >
>> > DATASET DECLARE true1.
>> > AGGREGATE
>> > � /OUTFILE='true1'
>> > � /BREAK=EventRefNum to IncidentswithLA
>> > � /LegalActDate_min=MIN(LegalActDate).
>> >
>> > I have had the experience of an aggregate not aggregating. I found
>> that if
>> > I sorted by the break variable(s) first it worked. I started leaving
>> out
>> > sort when I learned that it is not essential. Not presorting seems to
>> save
>> > on processing time and memory used by the sort. But then sometimes
>> for some
>> > reason without the sort the aggregate doesn’t seem to work. No error
>> > message, just the same number of lines of data before and after the
>> > aggregate.
>> >
>> > Thanks
>> > Matt
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> > _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
>> _ _ _ _ _ _
>> >
>> >
>> > The information contained in this email is intended for the named
>> recipient(s)
>> >
>> > only. It may contain private, confidential, copyright or legally
>> privileged
>> >
>> > information. � If you are not the intended recipient or you have
>> received this
>> >
>> > email by mistake, please reply to the author and delete this email
>> immediately.
>> >
>> > You must not copy, print, forward or distribute this email, nor place
>> reliance
>> >
>> > on its contents. This email and any attachment have been virus
>> scanned. However,
>> >
>> > you are requested to conduct a virus scan as well. � No liability is
>> accepted
>> >
>> > for any loss or damage resulting from a computer virus, or resulting
>> from a delay
>> >
>> > or defect in transmission of this email or any attached file. This
>> email does not
>> >
>> > constitute a representation by the NSW Police Force unless the author
>> is legally
>> > entitled to do so.
>> >
>> >
>> >
>> >
>> >
>> > --
>> > ___________________________________________________________________
>> > Maurice Vergeer
>> > Department of communication, Radboud University
>> (*www.ru.nl*<http://www.ru.nl/>
>> > )
>> > PO Box 9104, NL-6500 HE Nijmegen, The Netherlands
>> >
>> > Visiting Professor Yeungnam University, Gyeongsan, South Korea
>> >
>> > Recent publications:
>> > -Vergeer, M., Hermans, L., & Sams, S. (accepted for publication).
>> > Online social networks and micro-blogging in political campaigning:
>> > The exploration of a new campaign tool and a new campaign style.
>> Party
>> > Politics.
>> > -Eisinga, R., Franses, Ph.H., & Vergeer, M. (2010). Weather
>> conditions
>> > and daily television use in the Netherlands, 1996–2005. International
>> > Journal of Meteorology.
>> >
>> > Webspace*
>> > **www.mauricevergeer.nl* <http://www.mauricevergeer.nl/>*
>> > **http://blog.mauricevergeer.nl/*
>> <http://blog.mauricevergeer.nl/>*
>> >
>> **www.journalisteninhetdigitaletijdperk.nl*<http://www.journalisteninhetdigitaletijdperk.nl/>
>> > maurice.vergeer (skype)
>> > ___________________________________________________________________
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> > _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
>> _ _ _
>> > _ _ _ _
>> >
>> > All mail is subject to content scanning for possible violation of NSW
>> > Police Force
>> > Electronic Messaging Policy. All NSW Police Force employees are
>> required to
>> > familiarise themselves with the content of the policy, found under
>> Policies
>> > on the
>> > NSW Police Force Intranet.
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> > _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
>> _ _ _ _ _ _
>> >
>> >
>> > The information contained in this email is intended for the named
>> recipient(s)
>> >
>> > only. It may contain private, confidential, copyright or legally
>> privileged
>> >
>> > information. � If you are not the intended recipient or you have
>> received this
>> >
>> > email by mistake, please reply to the author and delete this email
>> immediately.
>> >
>> > You must not copy, print, forward or distribute this email, nor place
>> reliance
>> >
>> > on its contents. This email and any attachment have been virus
>> scanned. However,
>> >
>> > you are requested to conduct a virus scan as well. � No liability is
>> accepted
>> >
>> > for any loss or damage resulting from a computer virus, or resulting
>> from a delay
>> >
>> > or defect in transmission of this email or any attached file. This
>> email does not
>> >
>> > constitute a representation by the NSW Police Force unless the author
>> is legally
>> > entitled to do so.
>> >
>> >
>> >
>>
>>
>> --
>> ___________________________________________________________________
>> Maurice Vergeer
>> Department of communication, Radboud University � (www.ru.nl)
>> PO Box 9104, NL-6500 HE Nijmegen, The Netherlands
>>
>> Visiting Professor Yeungnam University, Gyeongsan, South Korea
>>
>> Recent publications:
>> -Vergeer, M., Hermans, L., & Sams, S. (accepted for publication).
>> Online social networks and micro-blogging in political campaigning:
>> The exploration of a new campaign tool and a new campaign style. Party
>> Politics.
>> -Eisinga, R., Franses, Ph.H., & Vergeer, M. (2010). Weather conditions
>> and daily television use in the Netherlands, 1996–2005. International
>> Journal of Meteorology.
>>
>> Webspace
>> www.mauricevergeer.nl
>> http://blog.mauricevergeer.nl/
>> www.journalisteninhetdigitaletijdperk.nl
>> maurice.vergeer (skype)
>> ___________________________________________________________________
>>
>
>
> -----
> --
> Bruce Weaver
> [hidden email]
> http://sites.google.com/a/lakeheadu.ca/bweaver/
>
> "When all else fails, RTFM."
>
> NOTE: My Hotmail account is not monitored regularly.
> To send me an e-mail, please use the address shown above.
>
> --
> View this message in context: http://spssx-discussion.1045642.n5.nabble.com/Re-problem-with-Aggregate-function-reply-tp4267017p4268397.html
> Sent from the SPSSX Discussion mailing list archive at Nabble.com.
>
> =====================
> To manage your subscription to SPSSX-L, send a message to
> [hidden email] (not to SPSSX-L), with no body text except the
> command. To leave the list, send the command
> SIGNOFF SPSSX-L
> For a list of commands to manage subscriptions, send the command
> INFO REFCARD
>



--
___________________________________________________________________
Maurice Vergeer
Department of communication, Radboud University�  (www.ru.nl)
PO Box 9104, NL-6500 HE Nijmegen, The Netherlands

Visiting Professor Yeungnam University, Gyeongsan, South Korea

Recent publications:
-Vergeer, M., Hermans, L., & Sams, S. (accepted for publication).
Online social networks and micro-blogging in political campaigning:
The exploration of a new campaign tool and a new campaign style. Party
Politics.
-Eisinga, R., Franses, Ph.H., & Vergeer, M. (2010). Weather conditions
and daily television use in the Netherlands, 1996–2005. International
Journal of Meteorology.

Webspace
www.mauricevergeer.nl
http://blog.mauricevergeer.nl/
www.journalisteninhetdigitaletijdperk.nl
maurice.vergeer (skype)
___________________________________________________________________

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD
Reply | Threaded
Open this post in threaded view
|

Re: problem with Aggregate function - reply to Maurice

San K
In reply to this post by thara vardhan-2

Following code gives me exactly same results:

data list list / Erefnum Increfnum (2f5.0) legactdate(date11).

begin data

1234          5678            12-July-2010

142           233           12-Dec-2009

1234          5678           10-Feb-2010

1234          5678           19-Aug-2010

 163           999            3-Sep-2008

1234          5679            12-July-2010

 163           999           18-Sep-2008

1234          5679           10-Feb-2010

1234          5679           19-Aug-2010

end data.

 

AGGREGATE

  /OUTFILE=*

  /BREAK=Erefnum to Increfnum

  /LegalActDate_min=MIN(legactdate).

 

 AGGREGATE

  /OUTFILE=*

  /BREAK=Erefnum Increfnum

  /LegalActDate_min=MIN(legactdate)

  /N_BREAK=N.

 

 

Personally, I would never use the ‘TO’ unless it is an array or other set of variables like Jan TO Dec. It is simply not a good practise in my books for many reasons.

 

Anyway, your problem might be due to the memory issues. How many variables do you have between Erefnum and Increfnum?

You could try to join all these variables into one (an identifier) and then BREAK by that variable.

Eg:

COMPUTE idString = CONCAT( STRING(Erefnum, N4), “_”, STRING(Increfnum,N4) ).


Regards,
San


 
On Mon, Mar 28, 2011 at 4:25 PM, Thara Vardhan <[hidden email]> wrote:

Hi Maurice

Thanks for your reply.

No there is no problem with the date variable because in my original data file the legal action date is a date variable. Aggregate mode=add variables works perfectly within the same datafile using the legal action date.

Many thanks

regards
thara



Maurice Vergeer <[hidden email]>
Sent by: [hidden email]

28/03/2011 16:19

To
Thara Vardhan <[hidden email]>
cc
[hidden email]
Subject
Re: problem with Aggregate function - reply





Hi Thara

I assume the date is defined as a string variable? If so, and if your example is an exact copy of your actual data, there seems to be a space preceding the date in record one. I assume SPSS considers a space as less than 10, ergo record 1 is minimum.

I suggest you try to convert date to a date variable. Use the time/date wizard which is the easiest to use in this case.

I hope this helps.

Best wishes,
Maurice
 





On Sun, Mar 27, 2011 at 20:42, Thara Vardhan <
[hidden email]> wrote:

Hi Mathew


Thank you. Yes precisely that is my problem. The aggregate is not wokring despite my presorting the data file.


However if any member on the list would be kind enough to help me with an alternative solution I would be extremely grateful.


While most of the times I have  2 or 3 records with differing dates sometimes I also have 5 or 6 records with differring dates and I need to pick the record with the earliest legal action date to analyse my data.


for example


Erefnum Increfnum legactdate

1234          5678            12-July-2010

1234          5678           10-Feb-2010

1234          5678           19-Aug-2010



I need to pick record 2 - 10 feb 2010.  


looking foward to your reply.


regards

thara  


Thara,

 

If I’m understanding you correctly you’re saying that the following syntax is not really aggregating.

 

DATASET DECLARE true1.

AGGREGATE

 /OUTFILE='true1'

 /BREAK=EventRefNum to IncidentswithLA

 /LegalActDate_min=MIN(LegalActDate).


I have had the experience of an aggregate not aggregating. I found that if I sorted by the break variable(s) first it worked. I started leaving out sort when I learned that it is not essential. Not presorting seems to save on processing time and memory used by the sort. But then sometimes for some reason without the sort the aggregate doesn’t seem to work. No error message, just the same number of lines of data before and after the aggregate.

 

Thanks

Matt



















_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

The information contained in this email is intended for the named recipient(s) 
only. It may contain private, confidential, copyright or legally privileged 
information.  If you are not the intended recipient or you have received this 
email by mistake, please reply to the author and delete this email immediately. 
You must not copy, print, forward or distribute this email, nor place reliance 
on its contents. This email and any attachment have been virus scanned. However, 
you are requested to conduct a virus scan as well.  No liability is accepted 
for any loss or damage resulting from a computer virus, or resulting from a delay
or defect in transmission of this email or any attached file. This email does not 
constitute a representation by the NSW Police Force unless the author is legally 
entitled to do so.





--
___________________________________________________________________
Maurice Vergeer
Department of communication, Radboud University  (
www.ru.nl)
PO Box 9104, NL-6500 HE Nijmegen, The Netherlands

Visiting Professor Yeungnam University, Gyeongsan, South Korea

Recent publications:
-Vergeer, M., Hermans, L., & Sams, S. (accepted for publication).
Online social networks and micro-blogging in political campaigning:
The exploration of a new campaign tool and a new campaign style. Party
Politics.
-Eisinga, R., Franses, Ph.H., & Vergeer, M. (2010). Weather conditions
and daily television use in the Netherlands, 1996–2005. International
Journal of Meteorology.

Webspace

www.mauricevergeer.nl
http://blog.mauricevergeer.nl/
www.journalisteninhetdigitaletijdperk.nl
maurice.vergeer (skype)
___________________________________________________________________







_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

All mail is subject to content scanning for possible violation of NSW Police Force
Electronic Messaging Policy. All NSW Police Force employees are required to
familiarise themselves with the content of the policy, found under Policies on the
NSW Police Force Intranet.







_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

The information contained in this email is intended for the named recipient(s) 
only. It may contain private, confidential, copyright or legally privileged 
information.  If you are not the intended recipient or you have received this 
email by mistake, please reply to the author and delete this email immediately. 
You must not copy, print, forward or distribute this email, nor place reliance 
on its contents. This email and any attachment have been virus scanned. However, 
you are requested to conduct a virus scan as well.  No liability is accepted 
for any loss or damage resulting from a computer virus, or resulting from a delay
or defect in transmission of this email or any attached file. This email does not 
constitute a representation by the NSW Police Force unless the author is legally 
entitled to do so.