1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
* How do I select a range of date?

* Thanks for Jim Marks for suggesting the addition of this syntax.

DATA LIST FREE /id (F8.0) date1 (ADATE10).
BEGIN DATA
1 01/01/2001 2 03/15/2000 3 12/21/1999
4 11/11/2004 5 06/05/2002 6 07/15/2003
END DATA.

* Filter cases from 2001 on.
COMPUTE filt = XDATE.YEAR(date1) >= 2001.
FILTER BY filt.
SUMMARIZE
  /TABLES=date1
  /FORMAT=VALIDLIST NOCASENUM TOTAL
  /TITLE='Dates > 2001'
  /MISSING=VARIABLE
  /CELLS=NONE .


*Filter cases between Jan 2000 and June 30,2003.
USE ALL.
COMPUTE filt = RANGE(date1,DATE.MDY(1,1,2000),DATE.MDY(6,30,2003)).
FILTER BY filt.
EXECUTE.
SUMMARIZE
  /TABLES=date1
  /FORMAT=VALIDLIST NOCASENUM TOTAL
  /TITLE='Dates between Jan 1, 2000 and June 30,2003'
  /MISSING=VARIABLE
  /CELLS=NONE .