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
*(Q) I want to clean up a data file by deleting columns that have been
>added by previous syntax commands. I know all the possible column
>names that need to be deleted, but cannot be certain if they actually
>exist in the file or not.
>
>By using the SYNTAX,
>
>ADD FILES FILE=* /DROP acol01 acol2 bcol1 bcol2 (full list of all
>potential col names)
>
>I get an error if any column included in the command is not present in
>the file.
>As a result, no columns are deleted.
>
>Can anyone please point me in the right direction of how I can achieve
>what I want to do.
>I guess I could put each column in a new command
>
>
>ADD FILES FILE=* /DROP acol01 
>ADD FILES FILE=* /DROP acol02 
>ADD FILES FILE=* /DROP bcol01
>ADD FILES FILE=* /DROP bcol02
>
>But is this the only way?


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

DEFINE !delete(!POS=!CMDEND)
!DO !var !IN(!1)
ADD FILES FILE=* /DROP=!var.
!DOEND
!ENDDEFINE.

set mprint=yes.
!delete acol01 acol02 bcol01 bcol02.