Exporting output to a file using a syntax command

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

Exporting output to a file using a syntax command

Jarrod Teo
Hi anyone out there,



Currently I want to export a table from my output into an excel file.



I need a syntax command to do this; can someone help me on this?



Much thanks.



Cheers

Jarrod

=====================
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: Exporting output to a file using a syntax command

Peters Gj (PSYCHOLOGY)
Dear Jarrod,

>> Currently I want to export a table from my output into an excel file.
>> I need a syntax command to do this; can someone help me on this?

You can use the Output Management System to export something to a
tab-seperated plain-text file, and then drag it into an Excel window to
open it. Just include something like this at the point where you want to
start saving your output to the text-file:

    OMS /SELECT ALL /DESTINATION FORMAT = TABTEXT
      OUTFILE = "%USERPROFILE%\Desktop\temporary.txt" /TAG =
"outputToText".

And then when you're done, include this:

    OMSEND TAG=["outputToText"].

All output generated in between these two commands will then be saved.
You can also access these options from the menu, in OMS control panel in
Utilities (or generate syntax from there).

As far as I know (but I'm a novice :-)) you can't save directly to Excel
(as you can when you Export from the File menu), but when you drag the
resulting TXT file from this method into an Excel window, it will
automatically import it so that you can save it as an .XLS file.

HTH,

Gjalt-Jorn
_______________________
Gjalt-Jorn Ygram Peters

=====================
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: Exporting output to a file using a syntax command

Peters Gj (PSYCHOLOGY)
In reply to this post by Jarrod Teo
>>>> Currently I want to export a table from my output into an excel
file.
>>>> I need a syntax command to do this; can someone help me on this?

>> You can use the Output Management System to export something to a
tab-
>> seperated plain-text file, and then drag it into an Excel window to
open
>> it.

PS: I almost forgot: credits to Albert-Jan Roskam, who explained this to
me the 17th of December :-) He also said:

>> A (more flexible) Pythonian solution is also possible but it requires
>> knowledge of Xpath and the XML representation of a pivot table.
>> In addition: the SPSSAux/Python functions CreateXMLoutput and
>> GetValuesFromXMLWorkspace will simplify your code somewhat.
Interesting
>> stuff!

So that might help you if you know Python . . . I wouldn't know as I
don't, yet :-)

Kind regards,

Gjalt-Jorn
_______________________
Gjalt-Jorn Ygram Peters

=====================
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: Exporting output to a file using a syntax command

Pearmain, Michael
You can use that method with python, but for just exporting a few tables
the viewer module can do this.

(open the viewer module)

ExportDesignatedOutput(self, filespec, visibleContents=True,
format="html", raphics=True):
        """Export the contents of the designated Viewer to file
filespec.
        visibleContents = True (default) exports all visible contents;
if False, all contents are exported.
        format can be "html" (default), "text", "Excel", "Word",  "Ppt",
or "Pdf"
        Pdf requires at least SPSS 15.
        graphics = True (default) to include charts.  Ignored where the
format does not support it.
        """

Hth

Mike

-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of
Peters Gj (PSYCHOLOGY)
Sent: 09 January 2008 15:32
To: [hidden email]
Subject: Re: Exporting output to a file using a syntax command

>>>> Currently I want to export a table from my output into an excel
file.
>>>> I need a syntax command to do this; can someone help me on this?

>> You can use the Output Management System to export something to a
tab-
>> seperated plain-text file, and then drag it into an Excel window to
open
>> it.

PS: I almost forgot: credits to Albert-Jan Roskam, who explained this to
me the 17th of December :-) He also said:

>> A (more flexible) Pythonian solution is also possible but it requires
>> knowledge of Xpath and the XML representation of a pivot table.
>> In addition: the SPSSAux/Python functions CreateXMLoutput and
>> GetValuesFromXMLWorkspace will simplify your code somewhat.
Interesting
>> stuff!

So that might help you if you know Python . . . I wouldn't know as I
don't, yet :-)

Kind regards,

Gjalt-Jorn
_______________________
Gjalt-Jorn Ygram Peters

=====================
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
Reply | Threaded
Open this post in threaded view
|

Re: Exporting output to a file using a syntax command

Peck, Jon
In reply to this post by Jarrod Teo
Besides the Python approach, there are SaxBasic ways of exporting to Excel.  There is a downloadable script, Excel Export, on SPSS Developer Central (www.spss.com/devcentral) that does this.  That script does put up a dialog box, but the underlying automation method can be used syntactically.

But, in SPSS 14 and 15, if you have installed the Python plugin and the win32com module,  exporting all your visible tables to an Excel file is as simple as this.  Just change the file location to what you want (note the use of forward slashes in the filespec).

begin program.
import spss, viewer
app = viewer.spssapp()
app.ExportDesignatedOutput(filespec='c:/temp/myoutput.xls',format='Excel')
end program.

HTH,
Jon Peck

-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Jarrod Teo
Sent: Wednesday, January 09, 2008 2:40 AM
To: [hidden email]
Subject: [SPSSX-L] Exporting output to a file using a syntax command

Hi anyone out there,



Currently I want to export a table from my output into an excel file.



I need a syntax command to do this; can someone help me on this?



Much thanks.



Cheers

Jarrod

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