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
33
34
35
36
37
38
39
40
41
42
43
44
*To obtain a variable equal to current date.
*Date:         Thu, 7 Oct 1999 17:43:44 -0400.
*Reply-To:     emaguin@ACSU.BUFFALO.EDU.

*  Restructure current date in usable format.
STRING #tmo(A3).
COMPUTE #da=NUMBER(SUBSTR($DATE,1,2),F2.0).
COMPUTE #tmo=SUBSTR($DATE,4,3).
RECODE #tmo('JAN'=1)('FEB'=2)('MAR'=3)('APR'=4)('MAY'=5)('JUN'=6)('JUL'=7)
   ('AUG'=8)('SEP'=9)('OCT'=10)('NOV'=11)('DEC'=12) INTO #mo.

COMPUTE #yr=NUMBER(SUBSTR($DATE,8,2),F2.0).
COMPUTE currdate=DATE.MDY(#mo,#da,#yr).

FORMATS currdate(ADATE10).

*  mt1adate is just a date variable.
COMPUTE t1adays=(mt1adate-currdate)/(24*3600).

************************ next version is needed after 1/1/2000 ***************.
*Sent to SPSSX-L on 2000/09/12.

DATA LIST FREE /mydate(SDATE12).
BEGIN DATA
2000/01/01
END DATA.
LIST.

VARIABLE WIDTH mydate(11).
STRING #tmo(A3). 

*$DATE11 is a system variable string which contains the current date. 
* we have to transform it into a 'useable date'.

COMPUTE #da=NUMBER(SUBSTR($DATE11,1,2),F2.0).
COMPUTE #tmo=SUBSTR($DATE11,4,3).
RECODE #tmo('JAN'=1)('FEB'=2)('MAR'=3)('APR'=4)('MAY'=5)('JUN'=6)('JUL'=7)
('AUG'=8)('SEP'=9)('OCT'=10)('NOV'=11)('DEC'=12) INTO #mo. 
COMPUTE #yr=NUMBER(SUBSTR($DATE11,8,4),F4.0).
COMPUTE currdate=DATE.MDY(#mo,#da,#yr). 
FORMATS currdate(ADATE10). 
COMPUTE test1=currdate-mydate. 
COMPUTE days = CTIME.DAYS(test1) .
EXECUTE.