comapring cases

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

comapring cases

Alina Sheyman-3
I'm trying to compare several cases with the same id using spss. I've
identified duplicates and have them sorted and numbered in order, now I
need to do calculations on the last one in a sequence of identical id's. Is
there a code that will allow me to do an operation on the value if the next
value in the list is less than the current one? (Basically I just need to
grab the last record in  a sequence)

thank you
Reply | Threaded
Open this post in threaded view
|

Re: comapring cases

Melissa Ives
Look at the LAG() function or use AGGREGATE to keep the last record.

Melissa

-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of
Alina Sheyman
Sent: Wednesday, August 01, 2007 2:14 PM
To: [hidden email]
Subject: [SPSSX-L] comapring cases

I'm trying to compare several cases with the same id using spss. I've
identified duplicates and have them sorted and numbered in order, now I
need to do calculations on the last one in a sequence of identical id's.
Is there a code that will allow me to do an operation on the value if
the next value in the list is less than the current one? (Basically I
just need to grab the last record in  a sequence)

thank you


PRIVILEGED AND CONFIDENTIAL INFORMATION
This transmittal and any attachments may contain PRIVILEGED AND
CONFIDENTIAL information and is intended only for the use of the
addressee. If you are not the designated recipient, or an employee
or agent authorized to deliver such transmittals to the designated
recipient, you are hereby notified that any dissemination,
copying or publication of this transmittal is strictly prohibited. If
you have received this transmittal in error, please notify us
immediately by replying to the sender and delete this copy from your
system. You may also call us at (309) 827-6026 for assistance.
Reply | Threaded
Open this post in threaded view
|

Re: comapring cases

Ornelas, Fermin
In reply to this post by Alina Sheyman-3
I am not an spss expert but you aggregate by id then use the last
command to pull the last record for each id.  Something like:

SORT CASES BY CASEID
 AGGREGATE OUTFILE=*
     /PRESORTED
     /BREAK=CASEID
     /lastobs=last(varname)


Fermin Ornelas, Ph.D.
Management Analyst III, AZ DES
1789 W. Jefferson Street
Phoenix, AZ 85032
Tel: (602) 542-5639
E-mail: [hidden email]


-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of
Alina Sheyman
Sent: Wednesday, August 01, 2007 12:14 PM
To: [hidden email]
Subject: comapring cases

I'm trying to compare several cases with the same id using spss. I've
identified duplicates and have them sorted and numbered in order, now I
need to do calculations on the last one in a sequence of identical id's.

Is
there a code that will allow me to do an operation on the value if the
next
value in the list is less than the current one? (Basically I just need
to
grab the last record in  a sequence)

thank you

NOTICE: This e-mail (and any attachments) may contain PRIVILEGED OR
CONFIDENTIAL information and is intended only for the use of the
specific
individual(s) to whom it is addressed.  It may contain information that
is
privileged and confidential under state and federal law.  This
information
may be used or disclosed only in accordance with law, and you may be
subject to penalties under law for improper use or further disclosure of

the information in this e-mail and its attachments. If you have received

this e-mail in error, please immediately notify the person named above
by
reply e-mail, and then delete the original e-mail.  Thank you.
Reply | Threaded
Open this post in threaded view
|

Re: comapring cases

Richard Ristow
In reply to this post by Alina Sheyman-3
At 03:14 PM 8/1/2007, Alina Sheyman wrote:

>I'm trying to compare several cases with the same id using spss. I
>need to do calculations on the last one in a sequence of identical
>id's. (Basically I just need to grab the last record in  a sequence)

Well, if that's what you want, it's (not tested),

SORT CASES BY ID <whatever>.
ADD FILES
    /FILE=*
    /BY ID
    /LAST=LastOne.
SELECT IF LastOne.

Remarks (what's a posting of mine, without remarks?):

a. Notice "SORT CASES BY ID <whatever>." By "<whatever>" I mean one or
more other variables, to define the sequence, within ID, within which
you'll take the last record. It usually matters what sort order you
choose, i.e. what variables go into "<whatever>", but we can't say more
without knowing more about your study.

b. On the ADD FILES, it is "/BY ID", not "/BY ID <whatever>".

c. That "SELECT IF" *deletes* all cases but the last one for the ID.
Make sure you have a permanent copy of the file with all the data! And
you can, also,
FILTER BY LastOne.