Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Selecting cases in SPSS 16 that occur between two different dates

9,859 views
Skip to first unread message

Polly Higbee

unread,
Nov 3, 2010, 9:34:19 PM11/3/10
to
Hi there

I have a quite large SPSS database with cases that each have some date
variables in them (date format is dd.mm.yyy). I want to be able to
select cases which have a date variable that falls between two certain
dates (e.g. 01.01.1998 and 31.12.1998). Does anybody know what I
should enter in the selecting cases box to get this result?

I can't define dates as the cases do not go up in date incrementally.

Thank you so much in advance for any help

fred....@lsc.gov.uk

unread,
Nov 4, 2010, 4:10:45 AM11/4/10
to
not sure what you enter in the menus, but the syntax would be

select if =range(date
variable,date.dmy(1,1,1998),date.dmy(31,12,1998)).

Polly Higbee

unread,
Nov 4, 2010, 3:12:01 PM11/4/10
to
> > Thank you so much in advance for any help- Hide quoted text -
>
> - Show quoted text -

Hi thanks very much

I am entering
SELECT IF = RANGE (var00002,date.dmy(1,1,1998),date.dmy(31,12,1998)).
in the syntax box and keep getting this message in my output:


>Error # 4024 in column 11. Text: =
>The sequence of operators found is invalid. Check the expression for omitted
>or extra operands, operators, and parentheses.
>This command not executed.


Any suggestions?

Thanks so much :)

Bruce Weaver

unread,
Nov 4, 2010, 4:43:33 PM11/4/10
to

I'm not sure what you mean by "syntax box". If you are typing the
command into a syntax editor, just get rid of the = sign.

But it sounds like you might be using the Data - Select Cases GUI. If
you are, then the box should contain only this expression:

RANGE (var00002,date.dmy(1,1,1998),date.dmy(31,12,1998))

And you need to check the button to Delete the unselected cases. If
you then exit the dialog via PASTE (rather than Okay), it will
generate syntax similar to what you show above, but without the =
sign.

HTH.

--
Bruce Weaver
bwe...@lakeheadu.ca
http://sites.google.com/a/lakeheadu.ca/bweaver/Home
"When all else fails, RTFM."

Rich Ulrich

unread,
Nov 4, 2010, 5:06:10 PM11/4/10
to

Select If does not use an equal sign.

The code assumes that var00002 is a "date variable" as a number.

If you only want a particular year, you could use the appropriate
date function to extract the year and compare to 1998.

--
Rich Ulrich

Polly Higbee

unread,
Nov 4, 2010, 7:38:45 PM11/4/10
to
> bwea...@lakeheadu.cahttp://sites.google.com/a/lakeheadu.ca/bweaver/Home
> "When all else fails, RTFM."- Hide quoted text -

>
> - Show quoted text -

Oh this worked! Thank you so much, you have all been such a big help!
I really appreciate it.

0 new messages