Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: Re: openning an SPSS file

From   Garry Anderson <[email protected]>
To   [email protected]
Subject   Re: st: Re: openning an SPSS file
Date   Thu, 16 Oct 2003 18:43:43 +1000


There is a potential trap with the approach of 'saving as' a tab delimited file in SPSS and importing into Stata using 'insheet using filename'

If there is a missing value (no entry of a number) in any of the observations for a numeric variable in SPSS, SPSS outputs a space character in the saved tab-delimited file. When the file is read by Stata via 'insheet using filename', the space character converts the numeric variable into a string variable and doing the -summ var- command in Stata says that there are zero observations for this variable. This is because it is a string variable. I think that there is no need for SPSS to output a space character, but that is the way it is. Deleting the space character(s) in the tab-delimited file resolves the problem, but it is only a workaround. This occurs with Stata7 and Stata8.

Anothe workaround in Stata is to use
-destring, replace-

Regards, Garry
[email protected]

At 07:42 PM 15/10/2003 +0100, you wrote:

At 10:33 15/10/03 -0700, Ashley Fenzl wrote:
This seems like it would be an easy task, however I cannot find the answer on how to do it anywhere. Could someone please tell me how to open an SPSS file in Stata? Thank you. I appreciate the help!
I presume that Ashley has no access to StatTransfer, DBMS/Copy or other data conversion software. (This is the thing to use if possible. StatTransfer, in particular, can be called from within Stata using the -stcmd- package, distributed with StatTransfer or alternatively downloadable from SSC.)

If you type -findit spss- in Web-aware Stata, then Stata will inform you of the UCLA web page

which advises the user to use SPSS to write the data to a text file file using the menu sequence

File->Save as...

and then to input the text file into Stata using the -insheet- command. This will convert the variable names and values, but not the variable labels, value labels and formats. (To convert those, you need data conversion software.)

I hope this helps.


Roger Newson
Lecturer in Medical Statistics
Department of Public Health Sciences
King's College London
5th Floor, Capital House
42 Weston Street
London SE1 3QD
United Kingdom

Tel: 020 7848 6648 International +44 20 7848 6648
Fax: 020 7848 6620 International +44 20 7848 6620
or 020 7848 6605 International +44 20 7848 6605
Email: [email protected]

Opinions expressed are those of the author, not the institution.

* For searches and help try:
*   For searches and help try:

© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index