|
Hello Thara,
Try the following code by keeping in mind that: (a) I have not considered different date formats as I assume your data are already in SPSS format (the first part of my code generates some sample data for demostration purpose) (b) I have not considered the option whereby the assault is happening the same day as the intimidation but is recorded afterward (that is with an higher matchsequence) (c) I have tested it on my SPSS 15 and it seems working to me. * first i generate some sample data. NEW FILE. DATA LIST /PersonCNI 1-4 (A) matchsequence 6 eventdate 8-18 (date) IFC 20-50 (A). BEGIN DATA Mnop 1 06-MAR-2005 ACTUAL BODILY HARM Mnop 2 01-AUG-2005 ASSAULT COMMON Mnop 3 29-NOV-2005 ASSAULT COMMON Mnop 4 29-NOV-2005 INTIMIDATION JKL 1 22-JUL-2003 AGGRAVATED INDECENT ASSAULT JKL 2 22-JUL-2003 AGGRAVATED SEXUAL ASSAULT JKL 3 23-NOV-2003 ACTUAL BODILY HARM JKL 4 27-NOV-2004 ASSAULT COMMON JKL 5 24-OCT-2005 INTIMIDATION JKL 6 17-MAR-2006 ACTUAL BODILY HARM JKL 7 17-MAR-2006 SEXUAL ASSAULT END DATA. * i initialize the variable category. compute category=0. * i verify if there have been more than one intimidation event within each PersonCNI. AGGREGATE /OUTFILE=* MODE=ADDVARIABLES /BREAK=PersonCNI IFC /nrcases=N. IF IFC="INTIMIDATION" and nrcases>1 category=6. EXE. * then i sort the cases by PersonCNI and eventdate within each PersonCNI. SORT CASES BY PersonCNI eventdate. * now i compute the number of days between two events within the same PersonCNI. DO IF PersonCNI=LAG(PersonCNI). COMPUTE days=DATEDIF(eventdate, lag(eventdate), "days"). END IF. EXE. FORMAT days (F4.0). * i check if the assault occurs in the same day as intimidation (category 1). if IFC="INTIMIDATION" and days=0 and category<>6 category=1. EXE. * i check if the assault occurs before the intimidation (category 2). IF IFC="INTIMIDATION" and days>0 and category<>6 category=2. EXE. * i check if the assault occurs after the intimidation (category 3) after sorting the data in descending eventdate within the same PersonCNI. SORT CASES BY PersonCNI eventdate (D). DO IF PersonCNI=LAG(PersonCNI). COMPUTE days1=DATEDIF(eventdate, lag(eventdate), "days"). END IF. EXE. FORMAT days1 (F4.0). IF IFC="INTIMIDATION" and days1<0 and category<>6 category=3. EXE. * i finally check if the assault occurs both before and after the intimidation (category 4). IF IFC="INTIMIDATION" and days>0 and days1<0 and category<>6 category=4. EXE. * if the category is to be extended to all cases referred to the same person the following can do it. AGGREGATE /OUTFILE=* MODE=ADDVARIABLES OVERWRITEVARS=YES /BREAK=PersonCNI /category = MAX(category). HTH, Luca Mr. Luca MEYER Market research, data analysis & more www.lucameyer.com - Tel: +39.339.495.00.21 -----Messaggio originale----- Da: SPSSX(r) Discussion [mailto:[hidden email]] Per conto di Thara Vardhan Inviato: martedì 4 settembre 2007 6.42 A: [hidden email] Oggetto: seeking help with compute variable involving complex conditions Dear List members We are trying to study the association between Intimidation/Stalking and Assaults. I would be grateful if any member could help me with computing a new variable category. For each category that I need to compute - I am posting the sample records from my data file. Compute category 1- where actual bodily harm/common assault/sexual assault happened the same day as intimidation PersonCNI matchsequence eventdate IFC ABC 1 05 Feb2005 Assault common ABC 2 05 Feb 2005 Intimidation Compute category 2 ? where actual bodily harm/common assault/sexual assault happened before intimidation PersonCNI matchsequence eventdate IFC Mnop 1 06-MAR-2005 ACTUAL BODILY HARM Mnop 2 01-AUG-2005 ASSAULT COMMON Mnop 3 29-NOV-2005 ASSAULT COMMON Mnop 4 29-NOV-2005 INTIMIDATION this is where match seqence is important b'coz records 3 & 4 are on the same date for person CNI mnop but I need to make it category 2 since this person was a victim of assault and bodily harm before intimidation. Compute category 3 - where actual bodily harm/common assault/sexual assault happened after intimidation PersonCNI matchsequence eventdate IFC XYZ 1 02-NOV-2003 INTIMIDATION 2 04-NOV-2003 Actual Bodily Harm 3 26-DEC-2003 Assault Common 4 06-APR-2006 ACTUAL BODILY HARM Compute category 4 ? where actual bodily harm/common assault/sexual assault happened before and after intimidation PersonCNI matchsequence eventdate IFC JKL 1 22-JUL-2003 AGGRAVATED INDECENT ASSAULT JKL 2 22-JUL-2003 AGGRAVATED SEXUAL ASSAULT JKL 3 23-NOV-2003 ACTUAL BODILY HARM JKL 4 27-NOV-2004 ASSAULT COMMON JKL 5 24-OCT-2005 INTIMIDATION JKL 6 17-MAR-2006 ACTUAL BODILY HARM JKL 7 17-MAR-2006 SEXUAL ASSAULT Compute category 6 ? where they had more than one intimidation incident on diff dates Person CNI matchsequence Eventdate IFC GHI 1 14-JUL-2005 INTIMIDATION GHI 2 04-DEC-2005 INTIMIDATION I would be thankful if any member could help me with this problem. looking forward to you reply. regards thara Thara Vardhan Senior Statistician Planning & Results Organisation Review and Support NSW Police Tel: (02) 8835-8526 This message and any attachment is confidential and may be privileged or otherwise protected from disclosure. If you have received it by mistake, please let us know by reply and then delete it from your system; you should not copy the message or disclose its contents to anyone. No virus found in this incoming message. Checked by AVG Free Edition. Version: 7.5.485 / Virus Database: 269.13.3/986 - Release Date: 03/09/2007 9.31 No virus found in this outgoing message. Checked by AVG Free Edition. Version: 7.5.485 / Virus Database: 269.13.3/986 - Release Date: 03/09/2007 9.31 ____________________________________________________________ Tiscali.Fax: registra gratis il tuo numero personale. Ricevi gratis i fax sulla tua casella di posta e li invii dal web. http://vas.tiscali.it/fax// |
| Free forum by Nabble | Edit this page |
