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
* Convert ages in year, month or days into years.
* RL 2003/05/26.

DATA LIST FIXED /age 1-3 (A).
BEGIN DATA
7Y
7 Y
>99
27Y
3m
10M
1D
28D
END DATA.

STRING age2(A3).
COMPUTE age2=UPCASE(age).

DO IF INDEX(age,'Y')>0.
- COMPUTE SUBSTR(age2,INDEX(age2,'Y'))="".
- COMPUTE agenum=NUMBER(age2,F8).

ELSE IF INDEX(age2,'M')>0.
- COMPUTE SUBSTR(age2,INDEX(age2,'M'))="".
- COMPUTE agenum=NUMBER(age2,F8)/12.

ELSE IF INDEX(age2,'D')>0.
- COMPUTE SUBSTR(age2,INDEX(age2,'D'))="".
- COMPUTE agenum=NUMBER(age2,F8)/365.

ELSE IF INDEX(age2,'>')>0.
- COMPUTE agenum=NUMBER(SUBSTR(age2,2),F8).
END IF.
EXECUTE.