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

programaticly create a SPSS file (.sav)

1,128 views
Skip to first unread message

rsmith

unread,
Mar 15, 2006, 3:40:24 PM3/15/06
to
Hello all-

I'm a web developer, and am brand new to SPSS. I give my web users the
ability to save result files in different formats (csv, tab delimited,
etc.) Many of the users take the CSV files, and upload them into SPSS.
This, as you know, is a multi-step process, and I would like to save
them some time by offering to save a .sav file for them. I saw the
SPSS i/o dll developer's guide documentation, but i don't see much
regarding how to interact with the i/o dll via a web application. Has
anyone worked with the SPSS i/o dll to do something like this?
Pseudo/Sample code would be much appreciated!

Many Thanks!

Bruce Weaver

unread,
Mar 15, 2006, 4:04:33 PM3/15/06
to

I don't have an answer to that, but will suggest another approach for
you to consider. It might be easier for you to generate the SPSS
syntax to import the CSV or tab delimited file. (A syntax file is just
a text file with .SPS as the extension.) This is the way EpiData
(www.epidata.dk) exports data (from a text file) to SPSS. The user
simply runs the syntax generated by EpiData.

--
Bruce Weaver
bwe...@lakeheadu.ca
www.angelfire.com/wv/bwhomedir

rsmith

unread,
Mar 15, 2006, 4:11:07 PM3/15/06
to
Thanks for the quick reply Bruce! That is definately an option. If I
generate a syntax file for them, will the user be able to open the
syntax file up in SPSS without the multi-step process?

Bruce Weaver

unread,
Mar 15, 2006, 5:25:49 PM3/15/06
to

If you generate appropriate syntax, all they would have to do to import
the data to SPSS is open the syntax file (with SPSS) and click on
Run-->All.

Here are a few more details on the syntax EpiData generates:

1. It uses a DATA LIST command to import the data from a text file.
2. It assigns VARIABLE LABELS and VALUE LABELS.
3. It (optionally) saves the SPSS data file (.SAV) format.

To save the data in step 3, one has to uncomment one line of syntax by
removing the leading asterisk.

Tom

unread,
Mar 15, 2006, 5:44:51 PM3/15/06
to
Bruce Weaver wrote...

> I don't have an answer to that

Another solution is to look at the portable (.por) format.

Marc Halbruegge

unread,
Mar 19, 2006, 9:13:38 AM3/19/06
to
Writing .sav files using the i/o dll works like this:

spssOpenWrite (filename, &handle);
for (v in vars) {
spssSetVarName(handle, v.name, v.type);
spssSetVarLabel(handle, v.name, v.label);
}
spssCommitHeader(handle);

for (x in cases) {
for (v in vars) {
spssSetValueNumeric(...) / spssSetValueChar(...)
}
spssCommitCaseRecord(handle);
}

spssCloseWrite(handle);


Depending on the programming language of your web app, it's more or less
easy to incorporate this stuff. CGI would work, Java servlets would need
a JNI-call.
Another possibility is to do the SPSS stuff in a independent process
that monitors some directory on the web server were the web app puts the
data.

Greetings
Marc

rsmith

unread,
Mar 23, 2006, 12:28:47 PM3/23/06
to
Thanks Marc!

I'm implementing this using C# in a ASP.Net 2.0 environment. I guess
you have implemented SPSS file creation in a Web App before. The
vision I had was to give the user to ability to output the file as a
CSV or a SPSS, depending on their needs.

I tried to add the io dll as a reference in the project, but it
complains that no type libraries were found in teh component. I'm
guessing this is b/c this is unmanaged code...but i duno...

Ralph

Marc Halbruegge

unread,
Mar 23, 2006, 12:51:57 PM3/23/06
to
Hi Ralph!

> I'm implementing this using C# in a ASP.Net 2.0 environment. I guess
> you have implemented SPSS file creation in a Web App before. The
> vision I had was to give the user to ability to output the file as a
> CSV or a SPSS, depending on their needs.

Sorry, no web apps over here. I'm using the i/o-dll from standalone
programs. But the concepts stay the same ;)

> I tried to add the io dll as a reference in the project, but it
> complains that no type libraries were found in teh component. I'm
> guessing this is b/c this is unmanaged code...but i duno...

I guess so. I'm still using C++ (I really like it), so I'm not a big
help on C#.

Happy hacking,
Marc

neila...@msn.com

unread,
Mar 25, 2006, 6:54:36 PM3/25/06
to
Yep,
That DLL is old school. I developed a component using VB6 which is
a COM wrapper of most of the SPSSIO32.dll. It is optimized for speed.
Hitch, I can't give it away (I spent literally HUNDREDS of hours
developing
and testing it, and that is AFTER hundreds of hours of familiarity
with the
API)! Interested in a license? Contact me off list.
HTH, Neila

0 new messages