Creating SAS Transport Files

Starting with version 8, data sets are now portable across most, but not all, operating systems. Most SSCC users will never have to work with a transport file again. But for those who do, there is a new wrinkle: if you make a transport file using PROC COPY (probably what you're used to) variable names longer than eight characters will be truncated. This is so that the resulting transport file can be read in older versions of SAS. On the other hand, PROC CPORT does support long variable names, but the transport files it creates can only be read with SAS 8.

To repeat, most SSCC users will not have to use transport files. SAS data sets can be moved between all SSCC computers "as is." This document is most likely to be of interest if you are trying to make data available to the widest possible audience. If you are concerned about users of SAS 6, then you probably want to keep your variable names under eight characters and use PROC COPY. Otherwise use PROC CPORT. Just one warning: these methods don't mix. PROC COPY can't read files made with PROC CPORT and PROC CIMPORT cannot read files made with PROC COPY, so always tell the recipient which they should use.

The process of moving a SAS data set involves three steps. First, you must convert the data set into a transport file on the source computer. Second, move the transport file from the source computer to the destination computer. Third, convert the transport file back into a standard data set on the destination computer.

PROC CPORT

  1. To convert the data set to a transport file using PROC CPORT, run the following SAS program on the source computer.

    proc cport data='datafile' file=transfile;
    run;

    Replace datafile with the file name (and the path, unless it is your current directory) of the data file. Replace transfile with the name you want to give the transport file (and a path if you don't want it to go in the current directory).

  2. Move the transport file to the destination computer, using whatever method is available (SFTP, etc., but if you use SFTP make sure it is binary mode).

  3. To convert the transport file back to a regular data set, run the following on the destination computer.

    libname new 'newlocation';
    proc cimport library=new infile='transfile';
    run;

    Here transfile is the file created in step one (including the path where it ended up in step 2 if that's not the current directory). newlocation is the directory you want the data set to be put in.

PROC COPY

  1. To convert the data set to a transport file, run the following SAS program on the source computer.

    libname input 'datadirectory';
    libname output xport 'transfile';
    proc copy in=input out=output;
    select datafile;
    run;

    datadirectory is the current location of your data set and datafile is the file name. transfile is the name you want to give the transport file (you can also specify a path if you don't want it to go in the current directory).

  2. Move the transport file to the destination computer, using whatever method is available (SFTP, etc., but if you use SFTP make sure it is in binary mode).

  3. To convert the transport file back to a regular data set, run the following on the destination computer.

    libname input xport 'transfile';
    libname output 'newlocation';
    proc copy in=input out=output;
    run;

    Here transfile is the file created in step one (including the path where it ended up in step 2 if that's not the current directory). newlocation is the directory you want the data set to be put in.

 

Last Revised: 2/12/2002