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
************.
* QUESTION.
************.
A CGI Script of mine produces data that is formatted this way:

var1=4 var2=5 var3=6 var4=8

How can I import that into SPSS so that the name of the variable is left
out and it looks like this:

v1  v2  v3  v4
4   5   6   8

And there is another problem. If there is missing data in one cell the
corresponding variable is just left out, for example:

var1=4 var3=6 var4=8

(var2 is missing because there is missing data in it).

How can I import that into SPSS so that it looks like this:

v1  v2  v3  v4
4   .   6   8

********.
* ANSWER posted by rlevesque@videotron.ca to SPSSX-L on 2001/05/16.
********.

DATA LIST FIXED /a 1-80(A).
BEGIN DATA
var1=4 var2=5 var3=6 var4=8
var1=12 var3=34 var=1
END DATA.
LIST.


LOOP cnt=1 TO 4.
DO REPEAT var=var1 TO var4 /vname='var1' 'var2' 'var3' 'var4' /v=v1 TO v4.
IF INDEX(a,vname)>0 v=NUMBER(SUBSTR(a,INDEX(a,vname)+5,2),F8.0).
END REPEAT PRINT.
END LOOP.
EXECUTE.