Multiple SAVE TRANSLATE files

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Multiple SAVE TRANSLATE files

Dennis Deck
I am trying to create a program to parse a big input file and save multiple (about 400) school level files using SAVE TRANSLATE.
I would like to avoid the tedious (and error prone) task of writing 400 sets of commands to do this.

I have constructed various macros but cannot seem to get syntax that works.  
I keep running into limitations in the use of SAVE TRANSLATE or other problems within the macros.  
Any suggestions?

Dennis Deck, PhD
RMC Research Corporation
111 SW Columbia Street, Suite 1200
Portland, Oregon 97201-5843
voice: 503-223-8248 x715
voice: 800-788-1887 x715
fax:  503-223-8248
[hidden email]

====================To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD
Reply | Threaded
Open this post in threaded view
|

Re: Multiple SAVE TRANSLATE files

Albert-Jan Roskam
Hi Dennis,

It's a pitty that there is no such thing as XSAVE
TRANSLATE.

define save_it ().
get file = 'd:\temp\real_sourcefile.sav'.
save outfile = 'd:\temp\copy_sourcefile.sav'.
!do !cnt = 1 !to 400.
get file = 'd:\temp\copy_sourcefile.sav'.
temporary.
select if byvar ne !cnt.
xsave outfile = 'd:\temp\copy_sourcefile.sav'.
select if byvar = !cnt.
save translate outfile =
!quote(!concat('d:\temp\outfile_',!cnt,'.xls')) / type
= xls / version = 8 / fieldnames.
!doend.
!enddefine.

set mprint = on.
save_it.

I didn't test this. First a copy of the original file
is made. That copy is overwritten by a file that does
not meet the by-variable condition (one of your 400
file parts), so the next loop will use a smaller file.
Second, the part of the file that does meet the
condition is saved as an xls file (assuming that
that's what you need).

It would be neater though to create Python script that
does this job. Perhaps the CSV module could be used
for this. I bet that would be a lot faster. But I am
not sure whether f_in = spss.Submit("get file =
'd:\temp\real_sourcefile.sav'.") would be an iterable
variable. Perhaps somebody else on this list has ideas
about this?

Cheers!!
Albert-Jan


--- Dennis Deck <[hidden email]> wrote:

> I am trying to create a program to parse a big input
> file and save multiple (about 400) school level
> files using SAVE TRANSLATE.
> I would like to avoid the tedious (and error prone)
> task of writing 400 sets of commands to do this.
>
> I have constructed various macros but cannot seem to
> get syntax that works.
> I keep running into limitations in the use of SAVE
> TRANSLATE or other problems within the macros.
> Any suggestions?
>
> Dennis Deck, PhD
> RMC Research Corporation
> 111 SW Columbia Street, Suite 1200
> Portland, Oregon 97201-5843
> voice: 503-223-8248 x715
> voice: 800-788-1887 x715
> fax:  503-223-8248
> [hidden email]
>
> ====================To manage your subscription to
> SPSSX-L, send a message to
> [hidden email] (not to SPSSX-L), with no
> body text except the
> command. To leave the list, send the command
> SIGNOFF SPSSX-L
> For a list of commands to manage subscriptions, send
> the command
> INFO REFCARD
>



      ____________________________________________________________________________________
Never miss a thing.  Make Yahoo your home page.
http://www.yahoo.com/r/hs

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD