date variable

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

date variable

Arthur Kramer
I am using release 13.0.1.  I am trying to use a "select if" statement to
select cases after a particular date, e.g., after 30-JUN-2004.  When I treat
it as a string variable I get a message saying there are two operands, and
treating it as a numeric variable doesn't work, either.  Is there special
syntax for selecting with a date variable?





Arthur Kramer
Reply | Threaded
Open this post in threaded view
|

Re: date variable

Lemon, John S.
Arthur

Try ( untested )

SELECT IF ( TESTDATE GT ( YRMODA ( 2004, 06, 30 ) ) ).


Best Wishes

John S. Lemon
DIT - University of Aberdeen
Edward Wright Building: Room G51
Tel:  +44 1224 273350
Fax: +44 1224 273372



> -----Original Message-----
> From: SPSSX(r) Discussion [mailto:[hidden email]]
> On Behalf Of Arthur Kramer
> Sent: Thursday, August 24, 2006 2:39 PM
> To: [hidden email]
> Subject: date variable
>
> I am using release 13.0.1.  I am trying to use a "select if"
> statement to
> select cases after a particular date, e.g., after
> 30-JUN-2004.  When I treat
> it as a string variable I get a message saying there are two
> operands, and
> treating it as a numeric variable doesn't work, either.  Is
> there special
> syntax for selecting with a date variable?
>
>
>
>
>
> Arthur Kramer
>
Reply | Threaded
Open this post in threaded view
|

Re: date variable

Beadle, ViAnn
In reply to this post by Arthur Kramer
Help suggests this approach:

SELECT IF datevar > date.mdy(3,1,2006).

-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Arthur Kramer
Sent: Thursday, August 24, 2006 8:39 AM
To: [hidden email]
Subject: date variable

I am using release 13.0.1.  I am trying to use a "select if" statement to
select cases after a particular date, e.g., after 30-JUN-2004.  When I treat
it as a string variable I get a message saying there are two operands, and
treating it as a numeric variable doesn't work, either.  Is there special
syntax for selecting with a date variable?





Arthur Kramer
Reply | Threaded
Open this post in threaded view
|

Re: date variable

Carlos Renato-2
Dear Friend

    Uses this procedure for solve your problem:


COMPUTE RANGE_DATES =
RANGE(YOUR_DATA_VARIABLE,DATE.DMY(30,06,2006),DATE.DMY(30,06,2006))
.

And uses the new variable RANGE_DATES for select the range of dates using
the same with a filter variable.

FILTER OFF.

USE ALL.

SELECT IF(RANGE_DATES=1).

EXECUTE .

Carlos Renato - Statistician - Recife PE - Brazil - +55 81 35811246.
Reply | Threaded
Open this post in threaded view
|

Re: date variable

Richard Ristow
In reply to this post by Lemon, John S.
This is worth a note, because it's an SPSS 'gotcha':

At 09:44 AM 8/24/2006, John S. Lemon wrote:

>Try ( untested )
>SELECT IF ( TESTDATE GT ( YRMODA ( 2004, 06, 30 ) ) ).

YRMODA returns the number of *days* since October 14, 1582 (day 0 of
the Gregorian calendar).

Current SPSS date variables are stored as the number of *seconds* from
0 hours, 0 minutes, and 0 seconds of Oct. 14, 1582.

So YRMODA values are too small by a factor of 86,400, and won't work in
comparison with current date variables.

(As for the representation of date variables, I knew what it was, but I
was surprised how hard it is to find in the Command Syntax Reference.
In the SPSS 14 manual, it's on page 69, following the section on Date
and Time Formats. It's over 2 1/2 pages after the beginning of the Date
and Time section, near the bottom of page 66, and the last heading that
precedes it is "Example: DATE, ADATE, and JDATE".)