select cases based on different dates

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

select cases based on different dates

LaraVDB
Hi,

I want to select cases based on 2 conditions, but so far I am not able to do
so.

subject          date1          date2          date3
sub1             10-Nov-18   8-Nov-18
sub2             30-Oct-18    8-Nov-18
sub3              5-May-18    8-Nov-18     4-May-18

my first selection is when date2>date1 -> this is working
my second selection is to delete the cases where date3<date1  -> this is not
working because it also deletes the cases where date3 is empty

Currently my script looks likes this:
SELECT IF (date2>date1).
EXECUTE.
SELECT IF not (date3<date1).
EXECUTE.

How can I make this work?

Thanks



--
Sent from: http://spssx-discussion.1045642.n5.nabble.com/

=====================
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
Reply | Threaded
Open this post in threaded view
|

Re: select cases based on different dates

Jon Peck
I think the problem is that your dates are actually strings rather than date values.  As a string, a blank value computes as less than a nonblank value.

You should convert these variables to SPSS date values.  You can do this interactively in the Data Editor Variable View or with the ALTER TYPE command.

On Thu, Nov 8, 2018 at 7:13 AM LaraVDB <[hidden email]> wrote:
Hi,

I want to select cases based on 2 conditions, but so far I am not able to do
so.

subject          date1          date2          date3
sub1             10-Nov-18   8-Nov-18
sub2             30-Oct-18    8-Nov-18
sub3              5-May-18    8-Nov-18     4-May-18

my first selection is when date2>date1 -> this is working
my second selection is to delete the cases where date3<date1  -> this is not
working because it also deletes the cases where date3 is empty

Currently my script looks likes this:
SELECT IF (date2>date1).
EXECUTE.
SELECT IF not (date3<date1).
EXECUTE.

How can I make this work?

Thanks



--
Sent from: http://spssx-discussion.1045642.n5.nabble.com/

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


--
Jon K Peck
[hidden email]

===================== 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
Reply | Threaded
Open this post in threaded view
|

Re: select cases based on different dates

LaraVDB
I checked this, and my dates are actual dates...



--
Sent from: http://spssx-discussion.1045642.n5.nabble.com/

=====================
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
Reply | Threaded
Open this post in threaded view
|

Re: select cases based on different dates

Jon Peck
In that case, it is due to having missing values in date3.  You could define the condition as
missing(date3) or not date3 < date1.
to include the cases where date3 is missing.

On Thu, Nov 8, 2018 at 7:52 AM LaraVDB <[hidden email]> wrote:
I checked this, and my dates are actual dates...



--
Sent from: http://spssx-discussion.1045642.n5.nabble.com/

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


--
Jon K Peck
[hidden email]

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