Hi all.
I have a weird problem with date data. Using the syntax below, I am trying to identify which beginning and end date are within about 20 different period start and end dates. A small subset of the data is provided. When I ran the syntax it worked in all cases EXCEPT for those that have a start and end date that match the period start and end dates. See ID 113 The first 113, for variable inPeriod, should be a 1, since it is GE/LE the Prd1Start and Prd1End. The second 113 should be a 2 for the variable inPeriod. For the two 114 ID's the first should be 1 since both events were GE/LE and the second a 2 corresponding to their respective period start and end dates. But they remain at zero. I have tried to save as, .csv, xls to see if it removes any bad date formats then reopen in SPSS. I've also done this through Access, exporting it (and removing any formats) and reopening in SPSS. These haven't worked. I'm completely at a loss. I don't know why SPSS doesn't recognize that beginning and end dates are within/in a date range with the exact same dates. Or it may not be SPSS but me. And to note: yes the syntax is clunky and could probably be done better with do/repeats or loops, but I'm still pretty new at the syntax writing. Brandon. ID InPeriod BegDate EndDate Prd1Start Prd1End Prd2Start Prd2End 113 0 1/1/2003 1/2/2003 1/1/2003 1/2/2003 21-Feb-04 21-Feb-04 113 0 2/21/2004 2/21/2004 1/1/2003 1/2/2003 21-Feb-04 21-Feb-04 114 0 3/5/2002 3/5/2002 3/5/2002 3/5/2002 14-Sep-04 14-Sep-04 114 0 9/14/2004 9/14/2004 3/5/2002 3/5/2002 14-Sep-04 14-Sep-04 118 1 4/15/2004 5/11/2004 4/15/2004 10/23/2004 118 1 5/11/2004 6/23/2004 4/15/2004 10/23/2004 118 1 6/23/2004 8/12/2004 4/15/2004 10/23/2004 118 1 8/12/2004 10/23/2004 4/15/2004 10/23/2004 119 1 7/5/2001 7/6/2001 7/5/2001 5/13/2002 10-Jul-02 29-May-03 119 1 7/6/2001 7/10/2001 7/5/2001 5/13/2002 10-Jul-02 29-May-03 119 1 7/10/2001 7/10/2001 7/5/2001 5/13/2002 10-Jul-02 29-May-03 119 1 7/10/2001 8/6/2001 7/5/2001 5/13/2002 10-Jul-02 29-May-03 119 1 8/6/2001 5/13/2002 7/5/2001 5/13/2002 10-Jul-02 29-May-03 119 2 7/10/2002 7/11/2002 7/5/2001 5/13/2002 10-Jul-02 29-May-03 119 2 7/11/2002 7/16/2002 7/5/2001 5/13/2002 10-Jul-02 29-May-03 119 2 7/16/2002 9/11/2002 7/5/2001 5/13/2002 10-Jul-02 29-May-03 sort cases by id Begdate Enddate. Compute InPeriod = 0. if BegDate GE Prd1Start & EndDate LE Prd1End InPeriod = 1 . if BegDate GE Prd2Start & EndDate LE Prd2End InPeriod = 2 . if BegDate GE Prd3Start & EndDate LE Prd3End InPeriod = 3 . if BegDate GE Prd4Start & EndDate LE Prd4End InPeriod = 4 . if BegDate GE Prd5Start & EndDate LE Prd5End InPeriod = 5 . if BegDate GE Prd6Start & EndDate LE Prd6End InPeriod = 6 . if BegDate GE Prd7Start & EndDate LE Prd7End InPeriod = 7 . if BegDate GE Prd8Start & EndDate LE Prd8End InPeriod = 8 . if BegDate GE Prd9Start & EndDate LE Prd9End InPeriod = 9 . if BegDate GE Prd10Start & EndDate LE Prd10End InPeriod = 10 . if BegDate GE Prd11Start & EndDate LE Prd11End InPeriod = 11 . if BegDate GE Prd12Start & EndDate LE Prd12End InPeriod = 12 . if BegDate GE Prd13Start & EndDate LE Prd13End InPeriod = 13 . if BegDate GE Prd14Start & EndDate LE Prd14End InPeriod = 14 . if BegDate GE Prd15Start & EndDate LE Prd15End InPeriod = 15. if BegDate GE Prd16Start & EndDate LE Prd16End InPeriod = 16. if BegDate GE Prd17Start & EndDate LE Prd17End InPeriod = 17. if BegDate GE Prd18Start & EndDate LE Prd18End InPeriod = 18. if BegDate GE Prd19Start & EndDate LE Prd19End InPeriod = 19. if BegDate GE Prd20Start & EndDate LE Prd20End InPeriod = 20. ===================== 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 |
Without running your syntax or close examination,
are you sure your IF conditions are mutually exclusive?
If they are not and are not meant to be but represent an order of priority, then use DO IF instead. Rick Oliver Senior Information Developer IBM Business Analytics (SPSS) E-mail: [hidden email] From: Brandon Lassiter <[hidden email]> To: [hidden email], Date: 09/13/2013 10:40 AM Subject: Dates within Ranges Syntax doesn't work Sent by: "SPSSX(r) Discussion" <[hidden email]> Hi all. I have a weird problem with date data. Using the syntax below, I am trying to identify which beginning and end date are within about 20 different period start and end dates. A small subset of the data is provided. When I ran the syntax it worked in all cases EXCEPT for those that have a start and end date that match the period start and end dates. See ID 113 The first 113, for variable inPeriod, should be a 1, since it is GE/LE the Prd1Start and Prd1End. The second 113 should be a 2 for the variable inPeriod. For the two 114 ID's the first should be 1 since both events were GE/LE and the second a 2 corresponding to their respective period start and end dates. But they remain at zero. I have tried to save as, .csv, xls to see if it removes any bad date formats then reopen in SPSS. I've also done this through Access, exporting it (and removing any formats) and reopening in SPSS. These haven't worked. I'm completely at a loss. I don't know why SPSS doesn't recognize that beginning and end dates are within/in a date range with the exact same dates. Or it may not be SPSS but me. And to note: yes the syntax is clunky and could probably be done better with do/repeats or loops, but I'm still pretty new at the syntax writing. Brandon. ID InPeriod BegDate EndDate Prd1Start Prd1End Prd2Start Prd2End 113 0 1/1/2003 1/2/2003 1/1/2003 1/2/2003 21-Feb-04 21-Feb-04 113 0 2/21/2004 2/21/2004 1/1/2003 1/2/2003 21-Feb-04 21-Feb-04 114 0 3/5/2002 3/5/2002 3/5/2002 3/5/2002 14-Sep-04 14-Sep-04 114 0 9/14/2004 9/14/2004 3/5/2002 3/5/2002 14-Sep-04 14-Sep-04 118 1 4/15/2004 5/11/2004 4/15/2004 10/23/2004 118 1 5/11/2004 6/23/2004 4/15/2004 10/23/2004 118 1 6/23/2004 8/12/2004 4/15/2004 10/23/2004 118 1 8/12/2004 10/23/2004 4/15/2004 10/23/2004 119 1 7/5/2001 7/6/2001 7/5/2001 5/13/2002 10-Jul-02 29-May-03 119 1 7/6/2001 7/10/2001 7/5/2001 5/13/2002 10-Jul-02 29-May-03 119 1 7/10/2001 7/10/2001 7/5/2001 5/13/2002 10-Jul-02 29-May-03 119 1 7/10/2001 8/6/2001 7/5/2001 5/13/2002 10-Jul-02 29-May-03 119 1 8/6/2001 5/13/2002 7/5/2001 5/13/2002 10-Jul-02 29-May-03 119 2 7/10/2002 7/11/2002 7/5/2001 5/13/2002 10-Jul-02 29-May-03 119 2 7/11/2002 7/16/2002 7/5/2001 5/13/2002 10-Jul-02 29-May-03 119 2 7/16/2002 9/11/2002 7/5/2001 5/13/2002 10-Jul-02 29-May-03 sort cases by id Begdate Enddate. Compute InPeriod = 0. if BegDate GE Prd1Start & EndDate LE Prd1End InPeriod = 1 . if BegDate GE Prd2Start & EndDate LE Prd2End InPeriod = 2 . if BegDate GE Prd3Start & EndDate LE Prd3End InPeriod = 3 . if BegDate GE Prd4Start & EndDate LE Prd4End InPeriod = 4 . if BegDate GE Prd5Start & EndDate LE Prd5End InPeriod = 5 . if BegDate GE Prd6Start & EndDate LE Prd6End InPeriod = 6 . if BegDate GE Prd7Start & EndDate LE Prd7End InPeriod = 7 . if BegDate GE Prd8Start & EndDate LE Prd8End InPeriod = 8 . if BegDate GE Prd9Start & EndDate LE Prd9End InPeriod = 9 . if BegDate GE Prd10Start & EndDate LE Prd10End InPeriod = 10 . if BegDate GE Prd11Start & EndDate LE Prd11End InPeriod = 11 . if BegDate GE Prd12Start & EndDate LE Prd12End InPeriod = 12 . if BegDate GE Prd13Start & EndDate LE Prd13End InPeriod = 13 . if BegDate GE Prd14Start & EndDate LE Prd14End InPeriod = 14 . if BegDate GE Prd15Start & EndDate LE Prd15End InPeriod = 15. if BegDate GE Prd16Start & EndDate LE Prd16End InPeriod = 16. if BegDate GE Prd17Start & EndDate LE Prd17End InPeriod = 17. if BegDate GE Prd18Start & EndDate LE Prd18End InPeriod = 18. if BegDate GE Prd19Start & EndDate LE Prd19End InPeriod = 19. if BegDate GE Prd20Start & EndDate LE Prd20End InPeriod = 20. ===================== 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 |
In reply to this post by Brandon Lassiter
At 11:39 AM 9/13/2013, Brandon Lassiter wrote:
>Using the syntax below, I am trying to identify which beginning and >end date are within about 20 different period start and end dates. A >small subset of the data is provided. When I ran the syntax it >worked in all cases EXCEPT for those that have a start and end date >that match the period start and end dates. See ID 113 The first 113, >for variable inPeriod, should be a 1, since it is GE/LE the >Prd1Start and Prd1End. ... I can't reproduce this. With your posted data and the first two IF statements, I seem to get the right answers -- see variable NewInp at the end of the listing: InPe New ID riod BegDate EndDate Prd1Start Prd1End Prd2Start Prd2End Inp 113 0 01-JAN-03 02-JAN-03 01-JAN-03 02-JAN-03 21-FEB-04 21-FEB-04 1 113 0 21-FEB-04 21-FEB-04 01-JAN-03 02-JAN-03 21-FEB-04 21-FEB-04 2 114 0 05-MAR-02 05-MAR-02 05-MAR-02 05-MAR-02 14-SEP-04 14-SEP-04 1 114 0 14-SEP-04 14-SEP-04 05-MAR-02 05-MAR-02 14-SEP-04 14-SEP-04 2 118 1 15-APR-04 11-MAY-04 15-APR-04 23-OCT-04 . . 1 118 1 11-MAY-04 23-JUN-04 15-APR-04 23-OCT-04 . . 1 118 1 23-JUN-04 12-AUG-04 15-APR-04 23-OCT-04 . . 1 118 1 12-AUG-04 23-OCT-04 15-APR-04 23-OCT-04 . . 1 119 1 05-JUL-01 06-JUL-01 05-JUL-01 13-MAY-02 10-JUL-02 29-MAY-03 1 119 1 06-JUL-01 10-JUL-01 05-JUL-01 13-MAY-02 10-JUL-02 29-MAY-03 1 119 1 10-JUL-01 10-JUL-01 05-JUL-01 13-MAY-02 10-JUL-02 29-MAY-03 1 119 1 10-JUL-01 06-AUG-01 05-JUL-01 13-MAY-02 10-JUL-02 29-MAY-03 1 119 1 06-AUG-01 13-MAY-02 05-JUL-01 13-MAY-02 10-JUL-02 29-MAY-03 1 119 2 10-JUL-02 11-JUL-02 05-JUL-01 13-MAY-02 10-JUL-02 29-MAY-03 2 119 2 11-JUL-02 16-JUL-02 05-JUL-01 13-MAY-02 10-JUL-02 29-MAY-03 2 119 2 16-JUL-02 11-SEP-02 05-JUL-01 13-MAY-02 10-JUL-02 29-MAY-03 2 Number of cases read: 16 Number of cases listed: 16 Is there any chance that your variables have a non-zero time component -- that is, that they represent not the midnight that begins the date, but some later time in the day? That wouldn't show in the listing. =================================================== APPENDIX: Test data and code (not saved separately) =================================================== DATA LIST LIST/ ID InPeriod BegDate EndDate Prd1Start Prd1End Prd2Start Prd2End (F3,F2, 4ADATE10, 2DATE10). BEGIN DATA 113 0 1/1/2003 1/2/2003 1/1/2003 1/2/2003 21-Feb-04 21-Feb-04 113 0 2/21/2004 2/21/2004 1/1/2003 1/2/2003 21-Feb-04 21-Feb-04 114 0 3/5/2002 3/5/2002 3/5/2002 3/5/2002 14-Sep-04 14-Sep-04 114 0 9/14/2004 9/14/2004 3/5/2002 3/5/2002 14-Sep-04 14-Sep-04 118 1 4/15/2004 5/11/2004 4/15/2004 10/23/2004 118 1 5/11/2004 6/23/2004 4/15/2004 10/23/2004 118 1 6/23/2004 8/12/2004 4/15/2004 10/23/2004 118 1 8/12/2004 10/23/2004 4/15/2004 10/23/2004 119 1 7/5/2001 7/6/2001 7/5/2001 5/13/2002 10-Jul-02 29-May-03 119 1 7/6/2001 7/10/2001 7/5/2001 5/13/2002 10-Jul-02 29-May-03 119 1 7/10/2001 7/10/2001 7/5/2001 5/13/2002 10-Jul-02 29-May-03 119 1 7/10/2001 8/6/2001 7/5/2001 5/13/2002 10-Jul-02 29-May-03 119 1 8/6/2001 5/13/2002 7/5/2001 5/13/2002 10-Jul-02 29-May-03 119 2 7/10/2002 7/11/2002 7/5/2001 5/13/2002 10-Jul-02 29-May-03 119 2 7/11/2002 7/16/2002 7/5/2001 5/13/2002 10-Jul-02 29-May-03 119 2 7/16/2002 9/11/2002 7/5/2001 5/13/2002 10-Jul-02 29-May-03 END DATA. VAR WIDTH InPeriod (06). FORMATS BegDate TO Prd2End (DATE10). VAR WIDTH BegDate TO Prd2End (09). NUMERIC NewInp (F3). VAR WIDTH NewInp (6). sort cases by id Begdate Enddate. Compute NewInp = 0. if BegDate GE Prd1Start & EndDate LE Prd1End NewInp = 1 . if BegDate GE Prd2Start & EndDate LE Prd2End NewInp = 2 . LIST. ===================== 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 |
In reply to this post by Brandon Lassiter
Richard,
Yes, it the variables could have a non-zero time component. I never thought of that. The dates represent social service activities/events. That could be why it works for you and not with my particular file, which I guess is where the problem must lie. Is there anyway to get around that? Brandon. On Fri, 13 Sep 2013 12:48:25 -0400, Richard Ristow <[hidden email]> wrote: >At 11:39 AM 9/13/2013, Brandon Lassiter wrote: > >>Using the syntax below, I am trying to identify which beginning and >>end date are within about 20 different period start and end dates. A >>small subset of the data is provided. When I ran the syntax it >>worked in all cases EXCEPT for those that have a start and end date >>that match the period start and end dates. See ID 113 The first 113, >>for variable inPeriod, should be a 1, since it is GE/LE the >>Prd1Start and Prd1End. ... > >I can't reproduce this. With your posted data and the first two IF >statements, I seem to get the right answers -- see variable NewInp at >the end of the listing: > > InPe > ID riod BegDate EndDate Prd1Start Prd1End Prd2Start Prd2End Inp > >113 0 01-JAN-03 02-JAN-03 01-JAN-03 02-JAN-03 21-FEB-04 21-FEB-04 1 >113 0 21-FEB-04 21-FEB-04 01-JAN-03 02-JAN-03 21-FEB-04 21-FEB-04 2 >114 0 05-MAR-02 05-MAR-02 05-MAR-02 05-MAR-02 14-SEP-04 14-SEP-04 1 >114 0 14-SEP-04 14-SEP-04 05-MAR-02 05-MAR-02 14-SEP-04 14-SEP-04 2 >118 1 15-APR-04 11-MAY-04 15-APR-04 23-OCT-04 . . 1 >118 1 11-MAY-04 23-JUN-04 15-APR-04 23-OCT-04 . . 1 >118 1 23-JUN-04 12-AUG-04 15-APR-04 23-OCT-04 . . 1 >118 1 12-AUG-04 23-OCT-04 15-APR-04 23-OCT-04 . . 1 >119 1 05-JUL-01 06-JUL-01 05-JUL-01 13-MAY-02 10-JUL-02 29-MAY-03 1 >119 1 06-JUL-01 10-JUL-01 05-JUL-01 13-MAY-02 10-JUL-02 29-MAY-03 1 >119 1 10-JUL-01 10-JUL-01 05-JUL-01 13-MAY-02 10-JUL-02 29-MAY-03 1 >119 1 10-JUL-01 06-AUG-01 05-JUL-01 13-MAY-02 10-JUL-02 29-MAY-03 1 >119 1 06-AUG-01 13-MAY-02 05-JUL-01 13-MAY-02 10-JUL-02 29-MAY-03 1 >119 2 10-JUL-02 11-JUL-02 05-JUL-01 13-MAY-02 10-JUL-02 29-MAY-03 2 >119 2 11-JUL-02 16-JUL-02 05-JUL-01 13-MAY-02 10-JUL-02 29-MAY-03 2 >119 2 16-JUL-02 11-SEP-02 05-JUL-01 13-MAY-02 10-JUL-02 29-MAY-03 2 > >Number of cases read: 16 Number of cases listed: 16 > >Is there any chance that your variables have a non-zero time >component -- that is, that they represent not the midnight that >begins the date, but some later time in the day? That wouldn't show >in the listing. >=================================================== >APPENDIX: Test data and code (not saved separately) >=================================================== >DATA LIST LIST/ > ID InPeriod BegDate EndDate Prd1Start Prd1End Prd2Start Prd2End > (F3,F2, 4ADATE10, 2DATE10). >BEGIN DATA > 113 0 1/1/2003 1/2/2003 1/1/2003 1/2/2003 21-Feb-04 21-Feb-04 > 113 0 2/21/2004 2/21/2004 1/1/2003 1/2/2003 21-Feb-04 21-Feb-04 > 114 0 3/5/2002 3/5/2002 3/5/2002 3/5/2002 14-Sep-04 14-Sep-04 > 114 0 9/14/2004 9/14/2004 3/5/2002 3/5/2002 14-Sep-04 14-Sep-04 > 118 1 4/15/2004 5/11/2004 4/15/2004 10/23/2004 > 118 1 5/11/2004 6/23/2004 4/15/2004 10/23/2004 > 118 1 6/23/2004 8/12/2004 4/15/2004 10/23/2004 > 118 1 8/12/2004 10/23/2004 4/15/2004 10/23/2004 > 119 1 7/5/2001 7/6/2001 7/5/2001 5/13/2002 10-Jul-02 29-May-03 > 119 1 7/6/2001 7/10/2001 7/5/2001 5/13/2002 10-Jul-02 29-May-03 > 119 1 7/10/2001 7/10/2001 7/5/2001 5/13/2002 10-Jul-02 29-May-03 > 119 1 7/10/2001 8/6/2001 7/5/2001 5/13/2002 10-Jul-02 29-May-03 > 119 1 8/6/2001 5/13/2002 7/5/2001 5/13/2002 10-Jul-02 29-May-03 > 119 2 7/10/2002 7/11/2002 7/5/2001 5/13/2002 10-Jul-02 29-May-03 > 119 2 7/11/2002 7/16/2002 7/5/2001 5/13/2002 10-Jul-02 29-May-03 > 119 2 7/16/2002 9/11/2002 7/5/2001 5/13/2002 10-Jul-02 29-May-03 >END DATA. > > >VAR WIDTH InPeriod (06). >FORMATS BegDate TO Prd2End (DATE10). >VAR WIDTH BegDate TO Prd2End (09). > > > >NUMERIC NewInp (F3). >VAR WIDTH NewInp (6). > >sort cases by id Begdate Enddate. >Compute NewInp = 0. >if BegDate GE Prd1Start & EndDate LE Prd1End NewInp = 1 . >if BegDate GE Prd2Start & EndDate LE Prd2End NewInp = 2 . >LIST. > >===================== >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 ===================== 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 |
In reply to this post by Brandon Lassiter
Rick,
I tried the do if and I still have the same problem. Is there a way I can reformat the dates so they may lose what ever baggage they may have connected to them and then run my original syntax? Brandon On Fri, 13 Sep 2013 12:48:25 -0400, Richard Ristow <[hidden email]> wrote: >At 11:39 AM 9/13/2013, Brandon Lassiter wrote: > >>Using the syntax below, I am trying to identify which beginning and >>end date are within about 20 different period start and end dates. A >>small subset of the data is provided. When I ran the syntax it >>worked in all cases EXCEPT for those that have a start and end date >>that match the period start and end dates. See ID 113 The first 113, >>for variable inPeriod, should be a 1, since it is GE/LE the >>Prd1Start and Prd1End. ... > >I can't reproduce this. With your posted data and the first two IF >statements, I seem to get the right answers -- see variable NewInp at >the end of the listing: > > InPe > ID riod BegDate EndDate Prd1Start Prd1End Prd2Start Prd2End Inp > >113 0 01-JAN-03 02-JAN-03 01-JAN-03 02-JAN-03 21-FEB-04 21-FEB-04 1 >113 0 21-FEB-04 21-FEB-04 01-JAN-03 02-JAN-03 21-FEB-04 21-FEB-04 2 >114 0 05-MAR-02 05-MAR-02 05-MAR-02 05-MAR-02 14-SEP-04 14-SEP-04 1 >114 0 14-SEP-04 14-SEP-04 05-MAR-02 05-MAR-02 14-SEP-04 14-SEP-04 2 >118 1 15-APR-04 11-MAY-04 15-APR-04 23-OCT-04 . . 1 >118 1 11-MAY-04 23-JUN-04 15-APR-04 23-OCT-04 . . 1 >118 1 23-JUN-04 12-AUG-04 15-APR-04 23-OCT-04 . . 1 >118 1 12-AUG-04 23-OCT-04 15-APR-04 23-OCT-04 . . 1 >119 1 05-JUL-01 06-JUL-01 05-JUL-01 13-MAY-02 10-JUL-02 29-MAY-03 1 >119 1 06-JUL-01 10-JUL-01 05-JUL-01 13-MAY-02 10-JUL-02 29-MAY-03 1 >119 1 10-JUL-01 10-JUL-01 05-JUL-01 13-MAY-02 10-JUL-02 29-MAY-03 1 >119 1 10-JUL-01 06-AUG-01 05-JUL-01 13-MAY-02 10-JUL-02 29-MAY-03 1 >119 1 06-AUG-01 13-MAY-02 05-JUL-01 13-MAY-02 10-JUL-02 29-MAY-03 1 >119 2 10-JUL-02 11-JUL-02 05-JUL-01 13-MAY-02 10-JUL-02 29-MAY-03 2 >119 2 11-JUL-02 16-JUL-02 05-JUL-01 13-MAY-02 10-JUL-02 29-MAY-03 2 >119 2 16-JUL-02 11-SEP-02 05-JUL-01 13-MAY-02 10-JUL-02 29-MAY-03 2 > >Number of cases read: 16 Number of cases listed: 16 > >Is there any chance that your variables have a non-zero time >component -- that is, that they represent not the midnight that >begins the date, but some later time in the day? That wouldn't show >in the listing. >=================================================== >APPENDIX: Test data and code (not saved separately) >=================================================== >DATA LIST LIST/ > ID InPeriod BegDate EndDate Prd1Start Prd1End Prd2Start Prd2End > (F3,F2, 4ADATE10, 2DATE10). >BEGIN DATA > 113 0 1/1/2003 1/2/2003 1/1/2003 1/2/2003 21-Feb-04 21-Feb-04 > 113 0 2/21/2004 2/21/2004 1/1/2003 1/2/2003 21-Feb-04 21-Feb-04 > 114 0 3/5/2002 3/5/2002 3/5/2002 3/5/2002 14-Sep-04 14-Sep-04 > 114 0 9/14/2004 9/14/2004 3/5/2002 3/5/2002 14-Sep-04 14-Sep-04 > 118 1 4/15/2004 5/11/2004 4/15/2004 10/23/2004 > 118 1 5/11/2004 6/23/2004 4/15/2004 10/23/2004 > 118 1 6/23/2004 8/12/2004 4/15/2004 10/23/2004 > 118 1 8/12/2004 10/23/2004 4/15/2004 10/23/2004 > 119 1 7/5/2001 7/6/2001 7/5/2001 5/13/2002 10-Jul-02 29-May-03 > 119 1 7/6/2001 7/10/2001 7/5/2001 5/13/2002 10-Jul-02 29-May-03 > 119 1 7/10/2001 7/10/2001 7/5/2001 5/13/2002 10-Jul-02 29-May-03 > 119 1 7/10/2001 8/6/2001 7/5/2001 5/13/2002 10-Jul-02 29-May-03 > 119 1 8/6/2001 5/13/2002 7/5/2001 5/13/2002 10-Jul-02 29-May-03 > 119 2 7/10/2002 7/11/2002 7/5/2001 5/13/2002 10-Jul-02 29-May-03 > 119 2 7/11/2002 7/16/2002 7/5/2001 5/13/2002 10-Jul-02 29-May-03 > 119 2 7/16/2002 9/11/2002 7/5/2001 5/13/2002 10-Jul-02 29-May-03 >END DATA. > > >VAR WIDTH InPeriod (06). >FORMATS BegDate TO Prd2End (DATE10). >VAR WIDTH BegDate TO Prd2End (09). > > > >NUMERIC NewInp (F3). >VAR WIDTH NewInp (6). > >sort cases by id Begdate Enddate. >Compute NewInp = 0. >if BegDate GE Prd1Start & EndDate LE Prd1End NewInp = 1 . >if BegDate GE Prd2Start & EndDate LE Prd2End NewInp = 2 . >LIST. > >===================== >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 ===================== 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 |
In reply to this post by Brandon Lassiter
At 01:17 PM 9/13/2013, Brandon Lassiter wrote:
>Yes, it the variables could have a non-zero time component. I never thought >of that. The dates represent social service activities/events. That could be >why it works for you and not with my particular file, which I guess is where >the problem must lie. Is there anyway to get around that? Before the code that does the classifying, change the date values to pure dates by running DO REPEAT DateVal = BegDate EndDate Prd1Start TO Prd20End. . COMPUTE DateVal = XDATE.DATE(DateVal). Be sure to keep a copy of your data *with* the time parts, as you'll surely need them at some point. END REPEAT. ===================== 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 |
In reply to this post by Brandon Lassiter
Sorry -- too much typing, not enough proofreading. At the end of the
previous posting, it should be DO REPEAT DateVal = BegDate EndDate Prd1Start TO Prd20End. . COMPUTE DateVal = XDATE.DATE(DateVal). END REPEAT. Be sure to keep a copy of your data *with* the time parts, as you'll surely need them at some point. ===================== 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 |
In reply to this post by Brandon Lassiter
Yes yes yes. This worked. Thanks so much.
Brandon. On Fri, 13 Sep 2013 13:28:24 -0400, Richard Ristow <[hidden email]> wrote: >Sorry -- too much typing, not enough proofreading. At the end of the >previous posting, it should be > >DO REPEAT DateVal = BegDate EndDate > Prd1Start TO Prd20End. >. COMPUTE DateVal = XDATE.DATE(DateVal). >END REPEAT. > >Be sure to keep a copy of your data *with* the time parts, as you'll >surely need them at some point. > >===================== >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 ===================== 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 |
In reply to this post by Brandon Lassiter
At 11:39 AM 9/13/2013, Brandon Lassiter wrote:
>the syntax is could probably be done better with do/repeats or loops, ... If you like, try this, which is *not* tested; but has the advantage of being more compact, AND not changing the original values: NUMERIC #PureBeg #PureEnd (DATE12). COMPUTE #PureBeg=XDATE.DATE(BegDate). COMPUTE #PureEnd=XDATE.DATE(EndDate). Compute InPeriod = 0. DO REPEAT /PrdStart = Prd1Start Prd2Start Prd3Start Prd4Start Prd5Start Prd6Start Prd7Start Prd8Start Prd9Start Prd10Start Prd11Start Prd12Start Prd13Start Prd14Start Prd15Start Prd16Start Prd17Start Prd18Start Prd19Start Prd20Start /PrdEnd = Prd1End Prd2End Prd3End Prd4End Prd5End Prd6End Prd7End Prd8End Prd9End Prd10End Prd11End Prd12End Prd13End Prd14End Prd15End Prd16End Prd17End Prd18End Prd19End Prd20End /Prd# = 1 TO 20. . IF #PureBeg GE XDATE.DATE(PrdStart) & #PureEnd LE XDATE.DATE(PrdEnd) InPeriod=Prd#. END REPEAT. The way your data is laid out, you can't use TO to specify the lists of period start and end dates. You could put all the period start and end dates in a single vector and LOOP through them, two at a time, but I think the code would be far less clear. ===================== 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 |