( very useful TO) but still having problem with Aggregate function

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

( very useful TO) but still having problem with Aggregate function

thara vardhan-2

Hi David Marso

Thank you so much for letting us know that TO function also works for aggregate function.

This is extremely useful for me for the work I do.

I tried the same for my datafile.

It works but the problem is that the new data file is not picking up records where the legalact date is the earliest.
It is creating a new data file but with the same number of records (as in the original file).
 
DATASET DECLARE true1.
AGGREGATE
  /OUTFILE='true1'
  /BREAK=EventRefNum to IncidentswithLA
  /LegalActDate_min=MIN(LegalActDate).

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  

Can you please tell me where I am going wrong?

PS: I tried using  the 2 identifier variables - it works and gives me  a unique datafile with 1384 records. But then I need to bring all other variables as well.

 DATASET DECLARE test3.
 AGGREGATE
  /OUTFILE='test3'
  /BREAK=EventRefNum IncidentRefNum
  /LegalActDate_min=MIN(LegalActDate)
  /N_BREAK=N.

I have also tried the
   AGGREGATE
  /OUTFILE=* MODE=ADDVARIABLES

But there again while i get the minimum legalactdate in each record I need to select the records out in a separate file.


many thanks
regards
thara






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

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: ( very useful TO) but still having problem with Aggregate function

Matthew Pirritano

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

 

From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Thara Vardhan
Sent: Sunday, March 27, 2011 6:35 PM
To: [hidden email]
Subject: ( very useful TO) but still having problem with Aggregate function

 


Hi David Marso

Thank you so much for letting us know that TO function also works for aggregate function.

This is extremely useful for me for the work I do.

I tried the same for my datafile.

It works but the problem is that the new data file is not picking up records where the legalact date is the earliest.
It is creating a new data file but with the same number of records (as in the original file).
 
DATASET DECLARE true1.
AGGREGATE
  /OUTFILE='true1'
  /BREAK=EventRefNum to IncidentswithLA
  /LegalActDate_min=MIN(LegalActDate).

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  

Can you please tell me where I am going wrong?

PS: I tried using  the 2 identifier variables - it works and gives me  a unique datafile with 1384 records. But then I need to bring all other variables as well.

 DATASET DECLARE test3.
 AGGREGATE
  /OUTFILE='test3'
  /BREAK=EventRefNum IncidentRefNum
  /LegalActDate_min=MIN(LegalActDate)
  /N_BREAK=N.

I have also tried the
   AGGREGATE
  /OUTFILE=* MODE=ADDVARIABLES

But there again while i get the minimum legalactdate in each record I need to select the records out in a separate file.


many thanks
regards
thara





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

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: ( very useful TO) but still having problem with Aggregate function

Rich Ulrich
In reply to this post by thara vardhan-2
> Date: Mon, 28 Mar 2011 12:34:40 +1100
> From: [hidden email]
> Subject: ( very useful TO) but still having problem with Aggregate function
> To: [hidden email]
>
[snip]

>
> It works but the problem is that the new data file is not picking up
> records where the legalact date is the earliest.
> It is creating a new data file but with the same number of records (as
> in the original file).
>
> DATASET DECLARE true1.
> AGGREGATE
> /OUTFILE='true1'
> /BREAK=EventRefNum to IncidentswithLA
> /LegalActDate_min=MIN(LegalActDate).
>
> 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
>
> Can you please tell me where I am going wrong?

It looks like you have all your variables specified as
"Break" -- That will make every line unique when the details differ.

I think you say that you want to keep the FIRST record of ID/Event.
If you use Aggregate, you want to break on ID and event after
sorting on ID, event, and Date, specifying PRESORT.

Then the function that you use to select variables
should be "First( var-list )".

If that is what you want, you can get the same result without using
Aggregate or naming the variables.  With the file sorted on ID and
event, simply

Match files file= * /first= earliest.
execute.
select if    earliest.
execute.

--
Rich Ulrich


=====================
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