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

Getting SPSS Data to Excel (Automation from Excel)

29 views
Skip to first unread message

Hari

unread,
May 3, 2005, 11:56:23 AM5/3/05
to
Hi,

Is it possible to copy all CASES from SPSS to Excel for some VARIABLES
using excel automation. (assuming that number of cases in my SPSS Data
file doesnt exceed the 65536 limit of number of rows in an Excel
Worksheet)

a) Iam comfortable with excel and have been able to adopt code Zilched
from web-sites like http://peltiertech.com/Excel/XL_PPT.html for
automating other applications from Excel.
But I dont know whether it is possible to copy specific variables (All
cases within that variable) from a open SPSS data file and paste in to
Excel using the method outlined in Jon peltier's method. Please tell me
if the same is possible.

b) I came across a method described in
http://www.indiana.edu/~statmath/stat/all/odbc/printable.pdf where it
is possible to transfer data using ODBC (I have not worked with
databases and dont have any idea). But it says that "Remember, however,
that unlike SAS, SPSS can read only ODBC data sources and cannot serve
as an ODBC data source." Does this limitation exist in new versions of
SPSS also?

Is there any method through which I could accomplish transfer of data
from SPSS to Excel while sitting in Excel (Automation).

Please guide me.

Regards,
Hari
India

neila...@msn.com

unread,
May 3, 2005, 7:57:56 PM5/3/05
to
Hari,
To answer the question as posted:
Here is the simplest example -but in my humble opinion,
methodologically suspect-

Check the script help system for restrictions etc.
See also SelectTextData and SelectCells methods.

FWIW: I abhor using the clipboard and despise
applications which do so for data transfer.
To do this "correctly" have SPSS translate to XLS,
or if you're a true gearhead use the APIs from spssio32.dll
Neila

Option Explicit

Dim objSpssApp As Object
' ISPSSApp after setting reference to SPSSWin.tlb
'SPSS is running with active file.... etc...

Sub Main()
Set objSpssApp = GetObject(, "SPSS.Application")
With objSpssApp.Documents.GetDataDoc(0)
.SelectVariables "sex", "life"
.Copy
End With
Application.ActiveWorkbook.ActiveSheet.Paste
End Sub

Hari

unread,
May 4, 2005, 11:25:34 AM5/4/05
to
Hi Neila,

Thanks for the code, it works fine. I have a follow-up doubt. After
setting references to SPSS in excel , I get the arguments for
SelectVariables as StartVariable and EndVariable. If there are any
variables between "Sex" and "life" then they also get copied. Is there
any other Property/method in SPSS which would enable me to copy only
variables listed in the code. Also, in case the variables of my
interest are seperated by more than 256 columns then Copy method fails.
thats why wanted to know whether it would be possible to copy only
defined variables using some other method (automation).

I would try to explore (learn) the API method.

Regards,
Hari
India

neila...@msn.com

unread,
May 4, 2005, 1:17:50 PM5/4/05
to
Hari,

To do this "correctly" have SPSS translate to XLS,
(Supports a DROP or KEEP subcommand).
Neila

neila...@msn.com

unread,
May 4, 2005, 3:36:44 PM5/4/05
to
Hari,
Well, here is another way (but using the clipboard sucks).
MATCH FILES / FILE * / KEEP varlistyouwish.
then do the copy/paste thing, or better: SAVE TRANSLATE.....
HTH, Neila

Hari

unread,
May 5, 2005, 9:31:47 AM5/5/05
to
Hi Neila,

Thnaks a lot for your help.

Regards,
hari
India

Hari

unread,
May 5, 2005, 9:32:26 AM5/5/05
to
Hi Neila,

Thanks a lot for your help.

Regards,
Hari
India

0 new messages