SAS Institute. The Power to Know

Knowledge Base


TS-271

AN OVERVIEW OF TRANSPORTING SAS FILES BETWEEN HOSTS
BY David Shinn and David Driggs

ABSTRACT

The SAS System runs on many different host environments, often making it necessary to move SAS files from one host to another; this process is called transporting. This article provides an overview of transporting SAS files and includes numerous system-specific examples, a list of frequently-encountered problem areas and suggestions for avoiding difficulties.

INTRODUCTION

The process of moving SAS files from one host environment to another is called transporting. In order to move a SAS file from one host to another, the file must be converted to a format that can be recognized by the SAS System on other host systems. This format is called transport format. The transport process includes exporting the SAS file (putting the file into transport format), moving the transport file to another host environment via tape or communications software and importing the transport file (restoring the file to the format appropriate to the receiving host).

This article provides an overview of transporting SAS files. It provides numerous system-specific examples, a list of some common problem areas and helpful tips for transporting. While this article discusses transporting in the MVS, CMS, VMS, Windows, OS/2, DOS and UNIX environments, much of the information also applies to other operating systems as well. Transporting is discussed under both Version 6 and Version 5 of the SAS System, however more attention is devoted to transporting under Version 6 of the SAS System.

Since this article is an overview, it does not attempt to provide exhaustive coverage of transporting SAS files or of the various SAS procedures that are discussed here. There are SAS System publications available that provide in depth coverage of these areas. These publications are listed in the SUMMARY section of the article.

GENERAL INFORMATION ABOUT TRANSPORTING

Transport format is necessary if you want to move a SAS file from one machine to another machine where the two machines have a binary incompatibility, such as different representations of floating point numbers. When moving SAS files between machines where the two machines are running different operating systems, transport format should be used. If both the sending host and the receiving host are running the same operating system, transport format is not required. Transport format is not required when moving SAS tape-format libraries between MVS and CMS.

Transport files are sequential files containing SAS data sets, SAS catalogs or a SAS data library in transport format. There are two specific types of transport format. One type is used only for transporting SAS data sets. For example, under Release 6.06, the XPORT engine (which is used on the LIBNAME statement) can be used to create or read a transport file containing this format. The other type of transport format is created by PROC CPORT and must be read by PROC CIMPORT; this format must be used for transporting SAS catalogs.

In addition to using the XPORT engine, there are other tools that can be used to create or read transport files that contain transport format for data sets. However, these tools vary with different releases of the SAS System (and under Release 5.18, vary with different operating systems). The following list summarizes the tools that are available.

  • When using Release 6.06 or later, use the XPORT engine.
  • When using Release 6.04, use the SASV5XPT engine.
  • When using Release 5.18 under MVS, CMS or VSE, use PROC XCOPY.
  • When using Release 5.18 under VMS, AOS/VS or PRIMOS, use PROC COPY (with the EXPORT and IMPORT options) or use the TRANSPORT= data set option.

Transport format for SAS data sets (created by the XPORT or SASV5XPT engine or the COPY or XCOPY procedure) is the same for all SAS releases on all host environments. Therefore, a transport file containing this format can be transported to any release of the SAS System on any host. For example, if a transport file is created on Release 6.06 using the XPORT engine, it can be imported on Release 5.18 under CMS using PROC XCOPY or it can be imported on Release 6.04 using the SASV5XPT engine.

Transport format created by PROC CPORT can be recognized by the release on which it was produced or by a later release, but it will not be recognized by an earlier release. For example, if PROC CPORT is used to create a transport file on Release 6.06, this file cannot be imported on Release 5.18.

TRANSPORTING UNDER RELEASE 6.06 OR LATER

In Release 6.06 and later, the XPORT engine provides a convenient means for transporting SAS data sets. The XPORT engine is the recommended tool when only SAS data sets are transported.

The XPORT engine is generally used in conjunction with PROC COPY; using this approach makes it easy to create or read a transport file which contains one or more data sets from a SAS data library. Another approach is to use the SAS DATA step to create or read a transport file; specify the XPORT engine on the LIBNAME statement for the transport file and then create or read the file as you would a regular SAS data set.

In Release 6.06 or later, the CPORT procedure, coupled with PROC CIMPORT can be used to transport SAS catalogs, SAS data sets and SAS data libraries. These procedures are the only tools available for creating and reading transport files containing SAS catalogs.

TRANSPORTING UNDER RELEASE 5.18

The basic approach for transporting SAS data sets on Release 5.18 (under MVS, CMS and VSE) is to use PROC XCOPY with the EXPORT option to create a transport file and the IMPORT option to read a transport file. On Release 5.18 under VMS, AOS/VS and PRIMOS, use PROC COPY with the EXPORT option or the IMPORT option.

When transporting full-screen catalogs on Release 5.18 (under MVS, CMS, VMS, AOS/VS and PRIMOS), use PROC CPORT to create a transport file and PROC CIMPORT to import. On Release 5.18, PROC CPORT and PROC CIMPORT are used only for transporting full-screen catalogs. Graphics catalogs and user-written formats/informats cannot be transported between hosts using Release 5.18. However, if you have Release 6.06 or later running on both the sending and receiving hosts, you can use PROC V5TOV6 to convert these files to Version 6 on the sending host and then transport them.

TRANSPORTING IN THE MVS ENVIRONMENT

This section provides some system-specific examples of transporting on MVS as well as some common problems that users encounter. In addition to the problems listed here, refer to the "Guidelines for Avoiding Problems" section at the end of this article.

SOME COMMON PROBLEMS

The most common problem when creating or importing a transport file on MVS is failure to specify the correct DCB (Data Control Block) characteristics. The following DCB characteristics must be specified when referencing a transport file: LRECL=80, BLKSIZE=8000, RECFM=FB. These characteristics are necessary when using the XPORT engine, PROC CPORT, PROC CIMPORT and PROC XCOPY.

Another common problem occurs when communications software is used to move the file from another host to MVS. (In this article, the term communications software is used to refer to communications software that is used for sending or receiving data files.) Occasionally, the transport file does not have the proper DCB characteristics when it arrives on MVS. If the communications software does not allow you to specify file characteristics, try the following approach. First, create a file on MVS with the correct DCB specifications. Then, move the transport file from the other host to the newly created file on MVS using binary transfer.

TRANSPORTING UNDER RELEASE 6.06 OR LATER

The following examples demonstrate transporting SAS data sets and SAS catalogs on Release 6.06 under MVS. The COPY procedure is used with the XPORT engine for transporting SAS data sets and the CPORT and CIMPORT procedures are used for transporting SAS catalogs.

In this example, a transport file is written to tape. This job copies all SAS data sets in the SAS data library referenced by the libref OLD to the file referenced by the libref TRAN. Note the DCB characteristics that are used for the output file, TRAN. Also, note that a non-labeled tape is specified.

  //EXAMP1 JOB (,X101),'SMITH,B.',TIME=(0,5)
  // EXEC SAS606
  //TRAN DD DISP=NEW,UNIT=TAPE,
  //     VOL=SER=TRAN01,LABEL=(1,NL),
  //     DCB=(RECFM=FB,LRECL=80,BLKSIZE=8000)
  //SYSIN DD *
  libname old 'actxyz.sales91.sasdata';
  libname tran xport;
  proc copy in=old out=tran memtype=data;
  run;
  /*
 
The next program imports a transport file from tape. The job copies all SAS data sets, except DEPT10 and DEPT12, from the transport file to the library referenced by the libref NEW. Again, note the DCB characteristics that are used for the TRAN file.
  //EXAMP2 JOB (,X101),'SMITH,B.',TIME=(0,5)
  // EXEC SAS606
  //TRAN DD DISP=OLD,UNIT=TAPE,
  //     VOL=SER=TRAN02,LABEL=(1,NL),
  //     DCB=(RECFM=FB,LRECL=80,BLKSIZE=8000)
  //NEW DD DSN=ACTXYZ.EMPLOYEE.SASDATA,
  //    DISP=(NEW,CATLG),UNIT=SYSDA,SPACE=(TRK,(20,5))
  //SYSIN DD *
  libname tran xport;
  proc copy in=tran out=new;
    exclude dept10 dept12;
  run;
  /*
        
The next example uses the CPORT procedure to create a transport file containing SAS catalogs. This job copies all SAS catalogs from the SAS data library referenced by the libref OLD to the file referenced by the fileref PORTFILE. Note that if the "MEMTYPE=CATALOG" option is removed, all catalogs and data sets in the SAS data library are copied to the transport file. When creating a transport file on tape, the TAPE option must be used on the PROC CPORT statement. The CPORT procedure also requires correct DCB characteristics for the transport file.
  //EXAMP3 JOB (,X101),'SMITH,B.',TIME=(0,5)
  // EXEC SAS606
  //PORTFILE DD DISP=NEW,UNIT=TAPE,
  //    VOL=SER=TRAN11,LABEL=(1,NL),
  //    DCB=(RECFM=FB,LRECL=80,BLKSIZE=8000)
  //SYSIN DD *
  libname old 'actxyz.mylib.sascat';
  proc cport library=old file=portfile memtype=catalog
             tape;
  run;
  /*
The following job imports a transport file that contains SAS catalogs. The file must be created by PROC CPORT; otherwise, PROC CIMPORT can not read it. This job copies all SAS files from the transport file referenced by the fileref PORTFILE to the library referenced by the libref NEW. When importing from tape, the TAPE option must be included on the PROC CIMPORT statement.
  //EXAMP4 JOB (,X101),'SMITH,B.',TIME=(0,5)
  // EXEC SAS606
  //PORTFILE DD DISP=OLD,UNIT=TAPE,
  //   VOL=SER=TRAN12,LABEL=(1,NL),
  //   DCB=(RECFM=FB,LRECL=80,BLKSIZE=8000)
  //NEW DD DSN=ACTXYZ.NEWLIB.SASDATA,DISP=(NEW,CATLG),
  //    UNIT=SYSDA,SPACE=(TRK,(30,5))
  //SYSIN DD *
  proc cimport library=new infile=portfile tape;
  run;
  /*

TRANSPORTING UNDER RELEASE 5.18

The next example, under Release 5.18 on MVS, creates a transport file containing SAS data sets. Only the data sets JAN91, FEB91 and MAR91 are copied. The JCL is the same as that in the previous example of exporting SAS data sets on Release 6.06 under MVS, except SAS Release 5.18 is invoked rather than SAS Release 6.06. The XPORT engine is not available in Release 5.18, so the XCOPY procedure is used. The EXPORT option must be used on the PROC XCOPY statement.
  libname old 'actxyz.sales91.sasdata';
  proc xcopy in=old out=tran export;
    select jan91 feb91 mar91;
  run;
The following code imports a transport file containing SAS data sets. All data sets are imported. The JCL is the same as that in the previous example of importing SAS data sets on Release 6.06 under MVS, except SAS Release 5.18 is invoked rather than SAS Release 6.06. The IMPORT option must be used on the PROC XCOPY statement.
  proc xcopy in=tran out=new import;
  run;
When transporting full-screen catalogs on Release 5.18 under MVS, use PROC CPORT to create a transport file and PROC CIMPORT to read one. The CIMPORT procedure under Release 5.18 cannot read a transport file that was created by a SAS release later than Release 5.18.

TRANSPORTING IN THE VMS ENVIRONMENT

This section provides system-specific examples of transporting on VMS as well as some common problems that users encounter. In addition to the problems listed here, refer to the "Guidelines for Avoiding Problems" section at the end of this article.

SOME COMMON PROBLEMS

There are several problems that can prevent a transport file from being imported or exported correctly on VMS. One common problem, when exporting or importing via tape, is mounting the tape without specifying the /BLOCKSIZE=8000 option on the MOUNT command.

If a transport file is created on disk on Release 6.06 under VMS, it will have a record attribute of Carriage Return Carriage Control (but the file does not contain carriage control characters). When the file is moved via communications software, some communications software facilities actually insert a carriage control character after each record; this corrupts the file so that it cannot be imported by the SAS System on the receiving host. For example, this problem most commonly occurs when a transport file is sent to a personal computer or to the UNIX environment. If you get the following error message on a personal computer or under UNIX when trying to import a SAS data set transport file that was created on VMS, then the VMS Carriage Return Carriage Control attribute is probably the cause.

  ERROR: File libref.ALL is damaged.  I/O processing did not
         complete.
One way to determine if the file has a record attribute of Carriage Return Carriage Control attribute on VMS is to issue the following VMS command, where "tran-file" is your transport file name.
  $ DIR/FULL tran-file
This lists the attributes of your transport file.

If the record attribute of Carriage Return Carriage Control causes problems for you, then use the following approach to change the record attribute to NONE:

  1. Create a file called REMCC.FDL which contains the following:

       RECORD
          BLOCK_SPAN YES
          CARRIAGE_CONTROL NONE
          FORMAT  FIXED
          SIZE  80

  2. Issue the following statement, to create a new file
     called TRANS.NEWDAT with the correct attributes:

       $  CONVERT/FDL=REMCC.FDL TRANS.DAT TRANS.NEWDAT

  3. Issue the following command to confirm that the record
     attribute has been changed to NONE.

       $  DIR/FULL TRANS.NEWDAT
If you are running Release 6.08 of the SAS System on VMS at maintenance level TS405 and beyond, there is a new value for the CC= option, NONE, that will cause a transport file to be created with a record attribute of NONE. This option can be specified on the LIBNAME statement when the XPORT engine is used. It can also be used on the FILENAME statement when a transport file is created with the CPORT procedure.

The following example illustrates the use of the CC=NONE option on the LIBNAME statement.

  libname tran xport 'tran1.dat' cc=none;

  proc copy in=work out=tran memtype=data;
  run;
When a transport file is moved to VMS via communications software, the file attributes may become incorrect (for example, incorrect block size or variable length records rather than fixed length records). If you are unable to obtain a transport file with the correct attributes, then the reblocking program in the "Guidelines for Avoiding Problems" section (at the end of the article) may be helpful. When running Release 5.18 of the SAS System under VMS, the record format must be fixed with a record size of 80. In Release 6.06 or later under VMS, although the record format still must be fixed, the record size can be 80 or 512.

TRANSPORTING UNDER RELEASE 6.06 OR LATER

When exporting SAS data sets to tape on VMS, use the following approach.
  1. Issue the appropriate command at your site to make
     a tape drive available to your session.

  2. Issue the following DCL commands to mount the tape.
     You will need to substitute your tape device name in
     place of "$2$MUA0:".

        $ DEFINE TRANFL $2$MUA0:
        $ ALLOCATE TRANFL
        $ MOUNT/FOREIGN/BLOCKSIZE=8000 TRANFL

  3. Then, execute the following program.  The name 'TRANFL'
     on the LIBNAME statement refers to the logical name that
     is associated  with the tape drive.

        libname tport xport 'tranfl';
        libname old '[actxyz.oldlib]';
        proc copy in=old out=tport memtype=data;
        run;
The next program illustrates using the SAS data step to read a transport file. This approach is particularly useful if you want to select a subset of records from a data set that is in transport format. Here, only 20 records of a very large data set are imported.
  libname tport xport 'tranfl';
  data sample1;
    set tport.big1 (obs=20);
  run;
The following program creates a transport file containing all catalog entries in the SAS catalog OLD.MYCAT. Mount the tape as described above. The name 'TRANFL' on the FILENAME statement is the logical name associated with the tape drive. The TAPE option must be used on the PROC CPORT statement when creating a transport file on tape.
  filename tport 'tranfl';
  libname old '[actxyz.oldlib]';
  proc cport catalog=old.mycat file=tport tape;
  run;
The next program reads a transport file containing SAS catalogs. All SAS files are imported from tape.
  filename tport 'tranfl';
  libname new '[actxyz.newlib]';
  proc cimport library=new infile=tport tape;
  run;

TRANSPORTING UNDER RELEASE 5.18

When transporting SAS data sets on Release 5.18 under VMS, use PROC COPY with the EXPORT or IMPORT option. The IXTAPE fileref MUST be used under VMS Release 5.18 when referencing a transport file on tape.

Use the following approach when writing a data set transport file to tape. First, issue the appropriate command at your site to make a tape drive available to your session. Then, mount the tape with the following commands, where your tape device name is substituted for "$2$MUA0:".

  $ DEFINE IXTAPE $2$MUA0:
  $ ALLOCATE IXTAPE
  $ MOUNT/FOREIGN/BLOCKSIZE=8000 IXTAPE
Then, execute the following program. Only APR91, MAY91 and JUN91 are copied from the library OLD to the transport file on tape. When exporting SAS data sets, the EXPORT option must be used on the PROC COPY statement.
  libname old  '[actxyz.newlib]';
  proc copy in=old out=ixtape export;
    select apr91 may91 jun91;
  run;
When transporting full-screen catalogs on Release 5.18 under VMS, use PROC CPORT to create a transport file and PROC CIMPORT to read a transport file. The CIMPORT procedure under Release 5.18 cannot read a transport file that was created by a SAS release later than Release 5.18.

TRANSPORTING IN THE CMS ENVIRONMENT

This section provides system-specific examples of transporting on CMS as well as some common problems that users encounter. In addition to the problems listed here, refer to the "Guidelines for Avoiding Problems" section at the end of this article.

SOME COMMON PROBLEMS ON CMS

The most common problem when creating or importing a transport file on CMS is not specifying the correct DCB (Data Control Block) characteristics. The following DCB characteristics must be specified when referencing a transport file: LRECL 80, BLKSIZE 8000, RECFM FB. You can easily check the record format and record size of a file by using the FILELIST command.

When a transport file is moved via communications software, it is sometimes difficult to move the file so that it retains the correct DCB characteristics on CMS. You may have more success if you logon to CMS and "pull" the file from the other host, rather than logging onto the other host and sending the file to CMS. Also, check the documentation for your communications software to see if there are options that can be set for the DCB characteristics.

Sometimes, when a transport file is moved to CMS via communications software, the file's record length may be changed. If you find that it is not possible, with your communications software, to move the file without changing the file attributes, then the reblocking program in the "Guidelines for Avoiding Problems" section (at the end of this article) may be helpful.

TRANSPORTING UNDER RELEASE 6.06 OR LATER

Often, the most trouble-free method for transporting SAS files is to use a tape. You can use the following method when transporting SAS data sets to tape on CMS. First, mount the tape using the appropriate command at your site. The tape should be non-labeled. Next, execute the following program, where 'B' on the LIBNAME SALES91 statement is the minidisk where your library resides. Only the data sets SEPT91 and OCT91 are copied to the transport file on tape. TAP1 is the tape device associated with your session. You will need to substitute your tape device name in place of TAP1.
  cms filedef tran tap1 nl
      (recfm fb lrecl 80 blksize 8000;
  run;
  libname tran xport;
  libname sales91 'b';
  proc copy in=sales91 out=tran;
     select sept91 oct91;
  run;
The next program reads a transport file from tape containing SAS data sets.
  cms filedef tran tap1 nl
      (recfm fb lrecl 80 blksize 8000;
  run;
  libname tran xport;
  libname mylib 'a';
  proc copy in=tran out=mylib;
  run;
When exporting SAS catalogs to tape, you can use the following approach. The TAPE option must be used on the PROC CPORT statement. In this example, the FILENAME statement is used to specify the attributes of the fileref TRAN. Another approach for specifying the attributes of TRAN is to use the CMS FILEDEF statement.
  filename tran tape 'tap1' lrecl=80 blksize=8000
           recfm=fb label=nl;
  libname dept12 'a';
  proc cport library=dept12 file=tran memtype=catalog
             tape;
  run;

TRANSPORTING UNDER RELEASE 5.18

When running Release 5.18 under CMS, use the XCOPY procedure to create a transport file containing SAS data sets. The next program creates a transport file on tape. All data sets, except OCT89, NOV89 and DEC89, are copied from the SAS library SALES89. The EXPORT option must be used on the PROC XCOPY statement.
  cms filedef tran tap1 nl
      (recfm fb lrecl 80 blksize 8000;
  run;
  libname sales89 'c';
  proc xcopy in=sales89 out=tran export;
    exclude oct89 nov89 dec89;
  RUN;
When transporting full-screen catalogs on Release 5.18 under CMS, use PROC CPORT to create a transport file and PROC CIMPORT to read a transport file. The CIMPORT procedure under Release 5.18 cannot read a transport file that was created by a SAS release later than Release 5.18.

TRANSPORTING IN THE WINDOWS AND OS/2 ENVIRONMENTS

This section provides information about transporting on a personal computer running Release 6.08 and later under Windows and OS/2. In addition to the common problems listed here, refer to the "Guidelines for Avoiding Problems" section at the end of this article.

SOME COMMON PROBLEMS

A common problem when transporting to the PC via communications software is that carriage control characters are sometimes inserted after each record; this causes the file to become corrupted so that it cannot be imported, because it changes the file's original attributes. If you view the transport file in hexadecimal format, you can determine if carriage return characters have been inserted. In hexadecimal, a carriage return is represented by '0D' and a line feed is represented by '0A'. The following illustration shows the first 96 bytes of a transport file in hexadecimal. A carriage control character (followed by a line feed character) is inserted after each record in this file. Note the '0D0A' in the lower left hand corner (bytes 81 and 82).
48 45 41 44 45 52 20 52 45 43 4F 52 44 2A 2A 2A HEADER R ECORD***
2A 2A 2A 2A 4C 49 42 52 41 52 59 20 48 45 41 44 ****LIBR ARY HEAD
45 52 20 52 45 43 4F 52 44 21 21 21 21 21 21 21 ER RECOR D!!!!!!!
30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 00000000 00000000
30 30 30 30 30 30 30 30 30 30 30 30 30 30 20 20 00000000 000000
0D 0A 53 41 53 20 20 20 20 20 53 41 53 20 20 20 ..SAS     SAS
If you attempt to read a transport file that contains carriage return characters, the following error message is normally generated.
   ERROR: File libref.ALL is damaged.  I/O processing did not
          complete.
If you get this error message when reading a transport file that was moved from VMS to the PC, refer to the 'Transporting on VMS' section of the article.

EXAMPLES OF TRANSPORTING ON WINDOWS AND OS/2

The XPORT engine provides a convenient means for creating or reading SAS data sets in transport format. The CPORT and CIMPORT procedures are used when transporting SAS catalogs and SAS data sets.

The following program causes all data sets in the library referenced by the libref OLD to be copied in transport format to the file on disk (transpt.dat) which is referenced by the libref TRAN.

  libname tran xport 'c:\workdir\transpt.dat';
  libname old 'c:\olddir';
  proc copy in=old out=tran;
  run;
The next program creates a transport file containing SAS catalogs.
  filename portfl 'a:\mydir\tran1.dat';
  libname old 'a:\olddir';
  proc cport library=old file=portfl memtype=catalog;
  run;

TRANSPORTING IN THE DOS ENVIRONMENT

This section provides information about transporting on a personal computer running Release 6.04 of the SAS System under DOS. Transporting in the DOS environment is similar to transporting on Windows and OS/2. However, under Release 6.04, the SASV5XPT engine is used rather than the XPORT engine when reading and creating SAS data set transport files. The CPORT and CIMPORT procedures are used when transporting SAS catalogs created by SAS/AF and SAS/FSP and when transporting SAS data sets.

The following program causes all data sets in the library referenced by the libref OLD to be copied in transport format to the file on disk (transpt.dat) which is referenced by the libref TRAN.

  libname tran sasv5xpt 'c:\workdir\transpt.dat';
  libname old 'c:\olddir';
  proc copy in=old out=tran;
  run;
The next program creates a transport file containing SAS catalogs.
  filename portfl 'a:\mydir\tran1.dat';
  libname old 'a:\olddir';
  proc cport library=old file=portfl memtype=catalog;
  run;

TRANSPORTING IN THE UNIX ENVIRONMENT AND DERIVATIVES

One of the most common problems on UNIX involves difficulty importing a transport file directly from tape. This problem can often be solved by using the UNIX DD command (with the bs=8000 option) to block the file while copying it from tape to disk. Then, try importing the file from disk. The following example copies the file from a tape device to tran.dat, specifying a blocksize of 8000.
   dd if=/dev/tape1  of=tran.dat  bs=8000
The following program, under SAS Release 6.07, creates a data set transport file on tape. Only one data set, JUL91, is copied. In this example, '/dev/tape1' is the tape device name. Your tape device name must be substituted for '/dev/tape1'.
  libname tran xport '/dev/tape1';
  libname old '/users/myid';
  proc copy in=old out=tran;
    select jul91;
  run;
The next example, under SAS Release 6.07 or later, selects the catalog entries MENU1.PROGRAM and MENU2.PROGRAM from the SAS catalog OLD.CUSTOMER and writes them to the transport file PORTFILE. The transport file is written to disk.
  libname old '/users/myid/mydir';
  filename portfile '/users/myid/trans1.dat';
  proc cport catalog=old.customer
       file=portfile
       select=(menu1.program menu2.program);
  run;

ANOTHER APPROACH FOR TRANSPORTING: USE SAS/CONNECT

Another approach for transporting SAS files is to use SAS/CONNECT software (SAS Release 6.06 or later) or the micro-to-host link (SAS Release 6.04 or Release 5.18). These products are not discussed in this article, but are discussed fully in "SAS CONNECT Software: Usage and Reference, First Edition" and in "Micro-to-Host Link, Version 6, First Edition".

GUIDELINES FOR AVOIDING PROBLEMS

There are certain guidelines that you must follow when exporting or importing SAS files on any operating system. This section discusses general suggestions for avoiding potential transporting problems. These suggestions apply to transporting on most operating systems.
  • When transporting a file via communications software, always use BINARY (sometimes called IMAGE) format. The file must be moved byte-for-byte without modification.
  • When transporting a file via tape, always use a non-labeled tape. It may be possible to use a standard labeled tape, but it usually requires extra work to read the file on the receiving host.
  • You cannot use PROC CIMPORT to import a transport file unless the file was created by PROC CPORT. To determine whether the transport file was created by PROC CPORT, inspect the file by browsing it. For a transport file that was created by PROC CPORT, the first 50 characters (in ASCII) are as follows:
    **COMPRESSED** **COMPRESSED** **COMPRESSED** **COM
    
  • If the transport file was created by the XPORT engine, the first 50 characters (in ASCII) are as follows:
    HEADER RECORD*******LIBRARY HEADER RECORD!!!!!!!00
    
  • If a carriage control (or any other character) is inserted in a transport file, the file will be corrupted so that it cannot be imported. Some communications software or COPY utilities can insert a carriage control character at the end of each record.
  • The file's record length, blocksize or record format must not be modified when the file is copied or moved via communications software or via a copy utility.
  • If your communications software changes the file's record length, blocksize or record type, consult your communications software documentation. There is probably an option that permits you to specify a record length of 80, blocksize of 8000 and fixed length records.
  • When moving a file via communications software, you may be more successful invoking the facility from the receiving host rather than from the sending host. For example, when moving a transport file from VMS to CMS, you may be more successful if you logon to CMS and invoke the communications software there.
  • If the receiving host cannot import the transport file, try importing the file on the same host that created it. If the original host cannot import a file that it created, then the transport file was created incorrectly. It is a good habit to always test a transport file by importing it on the host that created it; if there is a problem, it is important to recognize it immediately.
  • If a transport file on the receiving host has an incorrect blocksize and you are unable to obtain a correct transport file, then try using the program shown later in this section to reblock the file. The resulting output file contains 80 byte, fixed length records. This program creates a copy of the transport file that often can be imported, unless the original transport file is corrupted.

    In this example, the record format of the original transport file is fixed and the record length is evenly divisible by 16. If the record format is fixed and the record length of your transport file is not evenly divisible by 16, then determine the greatest common denominator that divides into both 80 and the file record length; then substitute this number for all occurrences of 16 in the program. For example, if your transport file has a record length of 99, then 1 is the largest number that divides evenly into both 80 and 99. If your transport file has variable length records, then use 1 as the greatest common denominator instead of 16.

    One warning should be noted. Sometimes, when a file is moved via communications software, extra null characters are written at the end of the file to pad the remainder of the last record. When this reblocking program is used, any extra null characters in the resulting output file may cause extra observations (all zero values) to be added to the end of the last data set in the library. This can occur when importing a transport file containing SAS data sets (using the XPORT engine, for example).

      data _null_;
         /* Note: the INFILE and FILE statements must */
         /* be modified.  Substitute your file names. */
        infile 'your_transport.dat' eof=wrapup;
        file 'new_transport.dat' recfm=f lrecl=80;
        length inrec $16 outrec $80 nullrec $80;
        retain count 1 outrec nullrec;
        input inrec $char16. @@;
        substr(outrec, count, 16) = inrec;
        count + 16;
        if (count > 80) then do;
           put outrec $char80.;
           count=1;
        end;
        return;
      wrapup:;
        file log;
        nullrec = repeat('00'x,80);
        if outrec = nullrec then do;
          put 'WARNING: Null characters may have been'
           ' added at the end of transport file by'
           ' communications software or by a copy'
           ' utility.  For a dataset transport file,'
           ' this could result in extra null'
           ' observations being added at the end'
           ' of the last dataset.';
        end;
      run;
    
  • Problems may occur during importing if your transport file spans more than one tape. Rather than using multi-volume tapes, you should split the original library into two or more libraries and create a separate tape for each one. The original library can be restored of the receiving host.
  • It is often helpful to view a transport file in hexadecimal format after it has been transported. If the file has become corrupted, it may be possible to determine this by examining the hexadecimal characters.

    You can use the following method to inspect your file. First, create a sample transport file (that is known to be correct) on the receiving host, and examine it to see what the syntax should look like in hexadecimal. Now, examine the other transport file (the one in question) to see if the syntax of the hexadecimal code corresponds to that in the correct file. If the file has become corrupted, this may be obvious.

SUMMARY

This article has provided an overview of transporting SAS files. Many of the transporting problems that users encounter tend to fall into the categories that have been discussed. If you follow the guidelines as suggested, your transporting experience should be a successful one.

There are publications available that provide much additional information about transporting SAS files, including options not discussed here. The most complete information is available in "SAS Technical Report P-195, Transporting SAS files between Host Systems". Other helpful documentation includes the "SAS Procedures Guide, Version 6, Third Edition", the "SAS Language Reference, Version 6, First Edition", the "SAS Procedures Guide, Release 6.03 Edition" and the "SAS Users Guide to Basics, Version 5 Edition". The "SAS Companions" for various operating systems are also helpful.