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
45
46
47
48
49
*(Q) I would like syntax to calculate the Incremental AUC (area under the curve) 
	ignoring the sub-baseline segments.
* Numerical examples are given in http://www.fao.org/docrep/w8079e/w8079e0a.htm.
* and in http://www.fao.org/docrep/w8079e/w8079e00.gif.

*(A) Posted to SPSSX-L list by Raynald Levesque on 2002/06/19.
* http://pages.infinit.net/rlevesqu/index.htm. 


* Next sample data come from the above web site.
DATA LIST LIST /id meas0 meas15 meas30 meas45 meas60 meas90 meas120 iauc1 (9F8.1).
BEGIN DATA
0	4.3 6.3 7.9 5.3 4.1 4.6 4.9 114
1	4 6 6.7 5.5 5.3 5 4.2 155
2	4.1 5.8 8 6.5 5.9 4.8 3.9 179
3	4 5 5.8 5.4 4.8 4.2 4.4 93
4	4.1 6.3 9 8.7 6.7 5.7 3.9 279
5	5 7.1 8.8 8 5.6 5.4 4.2 155
END DATA.
LIST.

* Set the time constants for the horizontal axis.
DO REPEAT h = h0 h15 h30 h45 h60 h90 h120
/ t = 0 15 30 45 60 90 120.
COMPUTE h = t.
END REPEAT.
EXECUTE.


* trapezoidal integration of glusose = f(time) curve .
VECTOR time = h0 to h120.
VECTOR gluc = meas0 to meas120 .
COMPUTE iauc2 = 0.
LOOP #k = 2 to 7.
IF #k=2 inival = gluc(1).
DO IF (NOT(MISSING(gluc(#k)))).
COMPUTE minval=MIN(gluc(#k-1),gluc(#k)) - inival.
COMPUTE maxval=MAX(gluc(#k-1),gluc(#k)) - inival.
DO IF minval>0.
COMPUTE iauc2 = iauc2 + (time(#k) - time(#k -1))*((gluc(#k -1) + gluc(#k))/2-inival) .
ELSE IF maxval>0.
COMPUTE iauc2 = iauc2 + (time(#k) - time(#k -1))*(maxval / (maxval - minval)*maxval/2) .
END IF.
END IF.
END LOOP.

* Clean up.
MATCH FILES FILE=* /DROP=h0 h15 h30 h45 h60 h90 h120 minval maxval inival.
EXECUTE.