Princeton University Library Data and Statistical 
Services

Search DSS





Finding Data Analyzing Data Citing data

About Us


DSS lab consultation schedule
(Monday-Friday)
Sep 1-Nov 3By appt. here
Nov 6-Dec 15Walk-in, 2-5 pm*
Dec 18-Feb 2By appt. here
Feb 5-May 4Walk-in, 1-5 pm*
May 7-May 15Walk-in, 2-5 pm*
May 16-Aug 31By appt. here
For quick questions email data@princeton.edu.
*No appts. necessary during walk-in hrs.
Note: the DSS lab is open as long as Firestone is open, no appointments necessary to use the lab computers for your own analysis.

Follow DssData on Twitter
See DSS on Facebook

Home Online Help Statistical Packages DBMS Copy SAS File Conversion

Converting SAS Files to Another Package

Converting SAS system and transport files to another format such as Stata or SPSS can be tricky. How you convert it depends on how the file was created and on what platform.

Additionally, a SAS file created on one platform (such as UNIX) cannot be used on another platform (such as Windows) without converting it. You can either use SAS to do this conversion, or you can use DBMS/Copy.

Always remember: any SAS file, regardless of how it was created, needs to be ftp'd in binary format! If you are using an ftp program such as WSFTP, be sure the binary button is checked. If you are using a command-line ftp client, be sure to give the "binary" command before transferring the file.

Determining how the file was created.

The first indication as to how the file was created is the extension or second part of the filename:

  • ssd01 - SAS version 6.x data file created on UNIX or Windows
  • sd2 - SAS version 6.x data file created on Windows
  • ssd - SAS version 6.x data file created on DOS
  • sas7bdat - SAS version 7/8 data file created on either UNIX or Windows
  • ssd04 - SAS data file created on DEC/ALPHA
  • saseb$data - SAS data file created on VAX/VMS
  • v5x - SAS version 5 Transport file
  • v6x - SAS version 6 Transport file

You should note that the extensions for the Transport files are not always used, so the file may be a transport file but not have the extensions listed above.

Converting SAS Data Files

If the file is a SAS data file, then your best course of action is to use DBMS/Copy to do the conversion. There is one caveat, though: if the file was created with the "compress=yes" option, then DBMS/Copy will not be able to do the conversion. You will have to re-create the file with the "compress=no" option. Here's how:

  1. Create a file with a name like "trans.sas" and put the following lines in it:
    options compress=no;
    libname inp "directory-where-SAS-file-is-located";
    data inp.new-filename; set inp.original-filename;
    run;
    
    In this code, be sure to use just the first part of the filename, not the extension.
  2. From the UNIX command prompt, issue the command: sas trans
  3. You should then have a new file with the new filename and the extension appropriate to your operating system. You can then run DBMS/Copy on this new file.

Converting SAS Transport Files

Converting a SAS Transport file can be even more tricky since there are several ways of creating them. If the file does not have one of the extensions listed above, then you will need to actually look at the first few lines ofthe file itself for information. There are two possibilities:

  HEADER RECORD*******LIBRARY HEADER RECORD!!!!!!!000000000000000000000000000000
  SAS   SAS   SASLIB 6.08  MVS               23JUN95:10:37:32
  23JUN95:10:37:32
  HEADER RECORD*******MEMBER HEADER RECORD!!!!!!!000000000000000001600000000140
  HEADER RECORD*******DSCRPTR HEADER
  RECORD!!!!!!!000000000000000000000000000000

This indicates that this file was made using PROC COPY with either the XPORT or V5XPORT engines, or was created using PROC XCOPY. This is indicated by the "LIBRARY HEADER RECORD" in the first line. You can also see in the second line that it is version 6.08 and was created on the MVS operating system. Since this is a version 6.x file, the XPORT engine was used; if it were a version 5.x file, then the V5XPORT engine would be appropriate.

The other possibility is:

  **COMPRESSED** **COMPRESSED** **COMPRESSED** **COMPRESSED** **COMPRESSED********
  LIB CONTROL MVS::SP4.3.0 SAS6.08::D607WORK::TEMP::VAR COUNT 1::REC COUNT 10::RE
  C LEN8::1::SPAN CONTROL -1::120::2::40::NL::120::NAMEI:: :::::::: :::::::::::SPA
  N CONTROL 0::8::1::8::NL::8::A:::::SPAN CONTROL 0::8::1::8::NL::8::A ::::SPAN CO
  NTROL 0::8::1::8::NL::8::A0::::SPAN CONTROL 0::8::1::8::NL::8::A@::::SPAN CONTRO

This file was created using PROC CPORT, and, like the file above, is version 6.08 for MVS.

DBMS/Copy can convert either of these types of files, but it must have the proper file extension indicated above. Try changing the extension to the ones above and run DBMS/Copy on it. Every so often, though, things don't work as we would like and you may have to create a regular SAS data file and convert that.

  • Converting a file created with PROC COPY or PROC XCOPY:
    1. Write a program with the following lines:
          libname trans xport "path-and-filename-of-transport-file";
          libname out "directory-for-SAS-data-file";
          proc copy in=trans out=out;
          run;
      If the file were a version 5.x file, you would replace the XPORT with V5XPORT. Be sure to use the full filename, including the extension for the transport file.
    2. Execute the program.
    3. You should have a SAS datafile in the directory indicated in the "libname out" statement. If not, check the log for errors.

  • Converting a file created with PROC CPORT:
    PROC CPORT is often used to transport SAS files of different types, such as format libraries, SCL catalogs, and data files. You need to use PROC CIMPORT to convert them.
    1. Write a program with the following lines:
             filename trans "path-and-filename-of-transport-file";
             libname out "directory-for-SAS-data-file";
             proc cimport data=out.filename infile=trans;
             run; 
    2. Execute the program.
    3. You should have a SAS datafile in the directory indicated in the "libname out" statement. If not, check the log for errors.

This page last updated on: