Date: Tue, 8 Jul 2008 00:38:43 -0400
Reply-To: Richard Ristow <firstname.lastname@example.org>
Sender: "SPSSX(r) Discussion" <SPSSX-L@LISTSERV.UGA.EDU>
From: Richard Ristow <email@example.com>
Subject: Re: selective saving/writing to output file based on $casenum
Content-Type: text/plain; charset="us-ascii"; format=flowed
At 04:45 PM 7/7/2008, Bruce Colton wrote:
>In some of the work I do, I only need to output selected cases,
>based on $casenum. For example, I might have the following:
>do if $casenum >72 and $casenum <97.
>xsave outfile='c:\users\bruce\documents\data_xout1.sav' .
> /keep forecast1 to forecast5.
Since the obvious can get missed: As posted, this has a syntax error.
The closing period on the first line of the 'xsave' command closes
the command, so the '/keep' will be ignored.
That wouldn't cause your trouble, though. It should give an error
message to the effect that '/keep' is not a valid SPSS command, and
should write the file keeping all variables in their original order,
but otherwise it should work.
>This hasn't worked, resulting in 'I/O error, or not enough file
>space' message (I know I have enough space on my hard drive).
I agree that this likely isn't describing the real problem.
>My gut feeling is that forecast1 to forecast5, relying on cases
>prior to case #73, as well as the present case to be output(73 thru
>96), may be confusing SPSS.
The logic you gave us ought to work, as far as it goes, though you
say you also have a good deal of other code in the same
transformation program, including "variables with cumulative info
from prior cases."
However, you ask,
>Is selective case output possible in SPSS, especially when I am not
>outputting strictly current case variables, but computed variables
>with cumulative info from prior cases and the current case?
Selective output is possible and routine in SPSS; an XSAVE within a
DO IF construct is the standard way to do it.
XSAVE rarely causes trouble. Within the transformation program, it's
essentially a no-op statement with a side effect (writing the output
file). There are some restrictions, including
. You can't have two XSAVEs to the same file in one transformation program.
. For that reason, you can't use XSAVE within a DO REPEAT construct
. You can't use XSAVE to write to a file that's open and loaded in any dataset.
>I am not outputting strictly current case variables
XSAVE outputs variables from the current case. Period. On the other
hand, it's immaterial how the values in the current case were
calculated. There's no difficulty (or should be none) outputting
variables whose values are calculated over several cases, for example
by using LAG.
Viann Beadle wrote, "relying upon $casenum is really, really tricky
in that this variable is calculated on the fly as cases are passed".
That's true, but you shouldn't have trouble unless you have a SELECT
IF in the same program. Selective XSAVEs would be no problem.
So, does any of this help? Otherwise, we need your whole
transformation program, preferably with some test data.
-Good luck to you,
To manage your subscription to SPSSX-L, send a message to
LISTSERV@LISTSERV.UGA.EDU (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
For a list of commands to manage subscriptions, send the command