Date: Tue, 28 Jan 1997 12:58:44 -0500
Reply-To: Gloria Edwards <firstname.lastname@example.org>
Sender: "SPSSX(r) Discussion" <SPSSX-L@UGA.CC.UGA.EDU>
From: Gloria Edwards <gsedward@HAMLET.UNCG.EDU>
Subject: Re: SAS & SPSS (portable files)
Content-Type: TEXT/PLAIN; charset=US-ASCII
On Tue, 28 Jan 1997, nick nelson wrote:
> Marc Sardy wrote:
> > I am trying to convert a file that was in SAS ASCII to SPSS. I tried to
> > ge the file into a transportable SA so I could convert it for SPSS but I
> > get a Missing header error and it quits. Any Ideas?
> > MArc
> If it's an ASCII data file, the question of conversion does not
> arise, simply read it into SPSS using an appropriate data list command.
> Or am I missing the point somewhere?
Yes, a missing header command generally indicates that the file is not a
SAS portable file or that it got messed up somewhere. The header on a SAS
portable file should look something like this:
HEADER RECORD*******LIBRARY HEADER
RECORD!!!!!!!000000000000000000000000000000 SAS SAS SASLIB 6.08
If it is just an ASCII data file, Marc may want to create a SAS portable
data file and open this in SPSS rather than reconstructing data definition
statements for SPSS.
The following is a program that runs on VMS to create a SAS portable file
that may then be opened in SPSS for Windows (after stripping the VMS-style
carriage returns). The SAS programming language would be virtually the
same on most operating systems (i.e, this works in SAS for Windows as
well). The SAS program with comments:
/* This program converts a sas for vax/vms dataset into sas portable dataset.
This conversion uses the XPORT engine described on page 232 of the "SAS
Language" Reference Version 6 1st Edition. Additional information is
available on pages 59-60 of "SAS Technical Report P-195".
A SAS transportable file must be created to use the data on a different
/* PART 1: Create a SAS transportable file */
/* Step 1 is to specify the xport engine in a libname statement.
The portable file will be called sasport.dat. */
/* Step 2 is to specify the sas data library containing the sas data set(s) to
be converted into a portable file. In this example, a single sas data set
is stored in the subdirectory olddata. */
/* Step 3 uses proc copy to convert the sas dataset into a portable file */
/* Step 4 is a select statment that specifies which datasets in the directory
olddata should be included in the portable file. In this case the select
statment is not necessary because "sasdata" is the only sas dataset in the
directory olddata. If multiple data sets are present, however, the select or
exclude statement should be used to specify which datasets to convert */
libname trans xport 'scratch:[scratch.edwardsg]sasport.dat';
libname old 'scratch:[scratch.edwardsg.olddata]';
proc copy in=old out=trans;
/* Now you have created a SAS portable file called sasport.dat. This dataset
could be read with the XPORT engine on a VAX/VMS system. To read the file on
another operating system, however, requires extra processing of the file.
VMS uses carriage control characters that will cause problems when SAS portable
files are read on other operating systems. These carriage returns must be
stripped from the file before it is ftp'ed to another operating system. */
/* After stripping carriage returns, you will have a file that should then
be FTP'ed in binary mode to the correct operating system. It may, for
example, by read by either SAS or SPSS for windows. */
/* To read in SPSS for Windows, use the "get sas" command in the syntax window
and specify the appropriate directory and file name. For example,
GET SAS DATA="c:\temp\newport.dat".
After reading the file into the SPSS Data Editor, you will be able to save the
data as an SPSS for Windows (*.sav) file and open it directly in SPSS.
/* Note: The VMS command DIR/FULL newport.dat will show the file attributes for
the SAS portable file.