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
* How to restructure a file form many line to one line per case and calculate the relative contribution of each component.
* This illustrate a very useful technique.
* Raynald Levesque rlevesque@videotron.ca.

DATA LIST LIST /depart(A8) type(A2) value(F8.1).
BEGIN DATA.
anthro ft .8
anthro pt .2
anthro ot .3
engl ft .5
engl ft .7
engl pt .2
engl pt .2
engl ot .3
engl ot .3
engl ot .5
END DATA.
LIST.

IF type='ft' v1=value.
IF type='pt' v2=value.
IF type='ot' v3=value.


AGGREGATE
  /OUTFILE=*
  /BREAK=depart
  /ft '% ft' = SUM(v1) /pt '% pt' = SUM(v2) /ot '% ot' = SUM(v3).

COMPUTE tot_val=SUM(ft,pt,ot).
COMPUTE ft=ft*100/tot_val.
COMPUTE ot=ot*100/tot_val.
COMPUTE pt=pt*100/tot_val.
FORMAT ft ot pt (PCT8.1) tot_val(F8.1).


MATCH FILES FILE=* /KEEP=depart tot_val ft pt ot.
* The data editor shown that 
the sum of the anthro values is 1.3
61.5% of that amount resuts from ft
15.4% results from pt and
the balance, 23.1%, results from ot.