Chapter Contents

Previous

Next
Moving and Accessing SAS Files across Operating Environments

Reblocking a Transport File

At the target host, if you determine that the transport file has an incorrect block size and you are unable to obtain a transport file that contains the correct block size, then use the reblocking program to reblock the transport file.

Note:   The transport file against which the reblocking program is run must be uncorrupted; that is, no extra carriage returns or line feeds can be inserted. If the transport file is known to be corrupted, the reblocking program will fail.  [cautionend]

This program copies the transport file and produces a new transport file that contains 80-byte fixed block records.

Program that Reblocks a Transport File
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 irec $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 data set transport file,' ' this could result in extra null' ' observations being added at the end' ' of the last data set.'; end; run;

In the example, the record format of the original transport file is fixed and the record length is evenly divisible by 16.

If your record type is fixed, but the record length is not evenly divisible by 16, then determine the greatest common denominator that is divisible by both 80 and the transport file record length. Substitute this number for all occurrences of 16 in the preceding program.

For example, 80 is evenly divisible by 1, 2, 5, 8, and 10. A fixed record length of 99 for a transport file is evenly divisible by 1, 3, 9, and 11. Thus, 1 is the only common denominator, and is, therefore, both the lowest common denominator and the greatest common denominator.

Note:   If the transport file has a variable length record type, then use 1 instead of 16 as the greatest common denominator.  [cautionend]

CAUTION:
For a transport file that contains data sets, some communications software pads the final record with null characters. The reblocking program may add extra observations that contain all zero values to the end of the final data set in a library.  [cautionend]


Chapter Contents

Previous

Next

Top of Page

Copyright 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.