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
|
Thara, If I’m understanding you correctly you’re saying that the following syntax is not really aggregating. DATASET DECLARE true1. 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
|
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 |
Free forum by Nabble | Edit this page |