Preventing and Fixing Problems |
At the target computer, if you find out 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.
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 this 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 find 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. The only common denominator is 1. Therefore, 1 is 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.
The reblocking program might add extra observations that contain all 0 values to the end of the final data set in a library.
Copyright © 2009 by SAS Institute Inc., Cary, NC, USA. All rights reserved.