Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Is there a "clear all" command?

1,452 views
Skip to first unread message

Richard Ulrich

unread,
Aug 31, 2007, 12:34:40 AM8/31/07
to
I find myself wishing, again and again, for something
like a "clear all" command. I've looked and I haven't found
one, in the SPSS on-line help (v. 15), and by Googling this
group.... though Google-groups has been a bit flaky lately.

I fiddle with command options in order to get the
output that I want, etc., adding routines to the syntax
that I am saving for documentation and posterity.
Occasionally I check on data in the files, or open
new files (that I won't be using).


After running a sequence of procedures , I want to be sure that
my syntax contains everything that it needs, and nothing
extra. So, what I do these days, is to exit SPSS and start
over, running the completed file. In fact, I sometimes
exit SPSS and start over half a dozen times in an hour,
when I'm opening several files and possibly using FILTER.
- It is too easy for SPSS to take a file that is not named
in my Syntax, or whatever, so this avoids mistakes. I end
up with a clean listing.

So, it would be convenient if I could say CLEAR ALL,
and start over, including the statement numbering, without
doing an Exit from SPSS. The *only* file that I ever want
to keep open is the syntax file that I am going to run again.

This process of many-exits has a minor side effect, too,
that can contribute to errors, since SPSS insists on asking
for confirmation about Closing each and every window.
For instance, lately I multi-processed (like above) some
syntax that opened 14 temporary data windows, while
importing that many .csv files. So, I find myself
clicking YES or NO as fast as I can, saying that I don't
want to save anything, and I do want to exit.

Somewhere along there, I suddenly noticed, when some
Ns came up short, that I had saved "changes" to one data file
that I should not have. Why do I have to close all those
files separately? Closing-errors are less likely to happen if
I can choose to dump a *bunch* of changes all at once,
instead of having to re-validate, over and over.

(I do protect my permanent data files by making them
Read-only in Windows, but this was a file that had not
gotten that far yet.)

I've gone into some detail, since there may be more than
one solution that already exists, or there may be partial
solutions.

I'll be happy to hear suggestions.

--
Rich Ulrich, wpi...@pitt.edu
http://www.pitt.edu/~wpilib/index.html

Bruce Weaver

unread,
Aug 31, 2007, 7:31:32 AM8/31/07
to Rich Ulrich


A partial solution would be to use "DATASET CLOSE ALL", which as I
understand it will close (with no prompts) all but one of the open datasets.

--
Bruce Weaver
bwe...@lakeheadu.ca
www.angelfire.com/wv/bwhomedir
"When all else fails, RTFM."

JKPeck

unread,
Aug 31, 2007, 8:06:49 AM8/31/07
to

There is no CLEAR ALL, but there are
NEW FILE
CLEAR TRANSFORMATIONS
and
CLOSE (output) commands.

You could write a little Python code to find all the open datasets and
close them and close all the output windows. You could,
alternatively, use SaxBasic to iterate through all the windows (syntax
and output) and close them that way.

And you could invoke this little SaxBasic code through a custom button
you could put on your SPSS toolbars.

HTH,
Jon Peck

Bruce Weaver

unread,
Aug 31, 2007, 10:22:07 AM8/31/07
to

I was having trouble finding the CLOSE command, but then noticed that it
is OUTPUT CLOSE. Here's an example from the Help files.

GET FILE='c:\examples\data\Males.sav'.
FREQUENCIES VARIABLES=ALL.
OUTPUT SAVE OUTFILE='c:\examples\output\Males.spo'.
OUTPUT CLOSE *.

GET FILE='c:\examples\data\Females.sav'.
FREQUENCIES VARIABLES=ALL.

Related Topics

OUTPUT ACTIVATE
OUTPUT DISPLAY
OUTPUT NAME
OUTPUT NEW
OUTPUT OPEN
OUTPUT SAVE

Richard Ulrich

unread,
Aug 31, 2007, 10:15:07 PM8/31/07
to
On Fri, 31 Aug 2007 10:22:07 -0400, Bruce Weaver
<bwe...@lakeheadu.ca> wrote:

> JKPeck wrote:
> > On Aug 30, 11:34 pm, Richard Ulrich <Rich.Ulr...@comcast.net> wrote:

[snip, my original]


> >> I'll be happy to hear suggestions.

Jon> >

> > There is no CLEAR ALL, but there are
> > NEW FILE
> > CLEAR TRANSFORMATIONS
> > and
> > CLOSE (output) commands.
> >
> > You could write a little Python code to find all the open datasets and
> > close them and close all the output windows. You could,
> > alternatively, use SaxBasic to iterate through all the windows (syntax
> > and output) and close them that way.
> >
> > And you could invoke this little SaxBasic code through a custom button
> > you could put on your SPSS toolbars.
> >
> > HTH,
> > Jon Peck
> >

BW >

> I was having trouble finding the CLOSE command, but then noticed that it
> is OUTPUT CLOSE. Here's an example from the Help files.
>
> GET FILE='c:\examples\data\Males.sav'.
> FREQUENCIES VARIABLES=ALL.
> OUTPUT SAVE OUTFILE='c:\examples\output\Males.spo'.
> OUTPUT CLOSE *.
>
> GET FILE='c:\examples\data\Females.sav'.
> FREQUENCIES VARIABLES=ALL.
>
> Related Topics
>
> OUTPUT ACTIVATE
> OUTPUT DISPLAY
> OUTPUT NAME
> OUTPUT NEW
> OUTPUT OPEN
> OUTPUT SAVE

Thanks Jon, Bruce.

DATASET CLOSE ALL.
and OUTPUT CLOSE *.
may become a couple of my
favorite commands. DATASET CLOSE ALL will also
help prevent SPSS from carrying out whatever-it-can
on whatever-file-was-left-over, when I make some
mistake in opening a new file, so I will be using that
one in the middle of some runs.

I've never coded in Python or Sax Basic, but I could
be tempted to learn, if either one could gain the
other aims. Namely, I want to erase the knowledge of
a file handle (so I don't get a "WARNING" that it is being
redefined), and of line-numbering. I have been using
Insert-file-handle religiously, since you guys taught be
about it -- At the start of a run, it usually gets logged as
lines 12..16 or so. When I see line numbers of 250... ,
I know that this output I am looking at was not a clean
run from a clean start.

Thanks again.

Bruce Weaver

unread,
Sep 1, 2007, 10:13:02 AM9/1/07
to Rich Ulrich
Richard Ulrich wrote:

> Thanks Jon, Bruce.
>
> DATASET CLOSE ALL.
> and OUTPUT CLOSE *.
> may become a couple of my
> favorite commands. DATASET CLOSE ALL will also
> help prevent SPSS from carrying out whatever-it-can
> on whatever-file-was-left-over, when I make some
> mistake in opening a new file, so I will be using that
> one in the middle of some runs.
>
> I've never coded in Python or Sax Basic, but I could
> be tempted to learn, if either one could gain the
> other aims. Namely, I want to erase the knowledge of
> a file handle (so I don't get a "WARNING" that it is being
> redefined), and of line-numbering. I have been using
> Insert-file-handle religiously, since you guys taught be
> about it -- At the start of a run, it usually gets logged as
> lines 12..16 or so. When I see line numbers of 250... ,
> I know that this output I am looking at was not a clean
> run from a clean start.
>
> Thanks again.


Rich, I've noticed (in v15, and possibly earlier) that re-running a
macro definition no longer generates a warning. So you could use macros
instead of FILE HANDLE commands. E.g.,

define folder ()'C:\Program Files\SPSS\' !enddefine.
define datafile ()'1991 U.S. General Social Survey.sav' !enddefine.

GET FILE = folder + datafile .

JKPeck

unread,
Sep 1, 2007, 11:45:58 AM9/1/07
to

> I've never coded in Python or Sax Basic, but I could
> be tempted to learn, if either one could gain the
> other aims. Namely, I want to erase the knowledge of
> a file handle (so I don't get a "WARNING" that it is being
> redefined), and of line-numbering. I have been using
> Insert-file-handle religiously, since you guys taught be
> about it -- At the start of a run, it usually gets logged as
> lines 12..16 or so. When I see line numbers of 250... ,
> I know that this output I am looking at was not a clean
> run from a clean start.
>
> Thanks again.
>


You will be glad to know that we have removed that annoying warning
about redefining a handle from SPSS 16. (We killed off the warning
about redefining a macro in, I think, SPSS 15.)

There are still plenty of good reasons to get into Python. There are
fewer reasons to use SaxBasic.

Regards,
Jon Peck

Richard Ulrich

unread,
Sep 10, 2007, 11:53:40 PM9/10/07
to
- not long ago, I posted ....

On Fri, 31 Aug 2007 22:15:07 -0400, Richard Ulrich
<Rich....@comcast.net> wrote:

> On Fri, 31 Aug 2007 10:22:07 -0400, Bruce Weaver
> <bwe...@lakeheadu.ca> wrote:
>
> > JKPeck wrote:
> > > On Aug 30, 11:34 pm, Richard Ulrich <Rich.Ulr...@comcast.net> wrote:

[snip, previous]


>
> Thanks Jon, Bruce.
>
> DATASET CLOSE ALL.
> and OUTPUT CLOSE *.
> may become a couple of my
> favorite commands. DATASET CLOSE ALL will also
> help prevent SPSS from carrying out whatever-it-can
> on whatever-file-was-left-over, when I make some
> mistake in opening a new file, so I will be using that
> one in the middle of some runs.

Yes, I do like DATASET CLOSE ALL and OUTPUT CLOSE *.

I've placed those at the start of a couple of syntax files
while working on them, and the latter keeps the listing clean,
while the DATASET CLOSE does a good enough job of
letting me start out with a new file.

By the way,
OUTPUT CLOSE * .
has the nice feature of being part of the CLOSEd listing,
so it does not show up, at all.

I've also, recently, used the REPLACE( ) function that
Jon described, and that is nice, too -- I had trouble with
it at first because I thought it was a Command, not a
function, but I finally figured to say

COMPUTE NEWstring= REPLACE( ... ).

fred....@lsc.gov.uk

unread,
Sep 13, 2007, 7:22:00 AM9/13/07
to
At least on version 16 you have the option to turn off multiple data
set windows, which avoids the problems of having multiple data windows
open.
0 new messages