splitting file and saving output

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

splitting file and saving output

Bibel, Daniel (POL)
I have a file with several hundred cases - each case (set of rows)
uniquely identified by an agency id (a 9 character string).

What I would like to do is programmatically split the file based on
agency id, then save the output of each into a separate excel file.

I thought this could be done with a 'do repeat' but that doesn't work.

Help, please!

Dan Bibel

=====================
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: splitting file and saving output

Maguin, Eugene
Daniel,

Not a do repeat but a do if structure combined with an xsave command. As in

Do if (tag eq 134).
+  xsave outfile='<your filename 1>'.
else if (tag eq 135).
+  xsave outfile='<your filename 2>'.
Etc
End if.

However, be aware that there is a limit to how many files can be listed in
one do if structure. See the references for this. Although I can't help you
with it, I suspect that python may offer better flexibility for you. Others
can comment.

Gene Maguin



>>>I have a file with several hundred cases - each case (set of rows)
uniquely identified by an agency id (a 9 character string).

What I would like to do is programmatically split the file based on
agency id, then save the output of each into a separate excel file.

I thought this could be done with a 'do repeat' but that doesn't work.

Help, please!

Dan Bibel

=====================
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: splitting file and saving output

Peck, Jon
If this is to be done with 11.5, there is a very small limit on the number of XSAVE files you can use in a session, and you would still have to code the file names manually.

If you can use version 14 or later, Python programmability can solve this problem easily in a very general way.  Let us know.

-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Gene Maguin
Sent: Tuesday, February 10, 2009 8:04 AM
To: [hidden email]
Subject: Re: [SPSSX-L] splitting file and saving output

Daniel,

Not a do repeat but a do if structure combined with an xsave command. As in

Do if (tag eq 134).
+  xsave outfile='<your filename 1>'.
else if (tag eq 135).
+  xsave outfile='<your filename 2>'.
Etc
End if.

However, be aware that there is a limit to how many files can be listed in
one do if structure. See the references for this. Although I can't help you
with it, I suspect that python may offer better flexibility for you. Others
can comment.

Gene Maguin



>>>I have a file with several hundred cases - each case (set of rows)
uniquely identified by an agency id (a 9 character string).

What I would like to do is programmatically split the file based on
agency id, then save the output of each into a separate excel file.

I thought this could be done with a 'do repeat' but that doesn't work.

Help, please!

Dan Bibel

=====================
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

=====================
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