一方のファイル参照名から他方のファイル参照名にレコードをコピーし、そのレコードが正常にコピーされたかどうかを示す値を返します。
カテゴリ: | SASファイルI/O |
/* Set MSGLEVEL to I to write messages from FCOPY to the log. */
options msglevel=i;
filename src 'source.txt';
filename dest 'destination.txt';
/* Create an example file to copy. */
data _null_;
file src;
do i=1, 2105, 300312, 400501;
put i:words256.;
end;
run;
/* Copy the records of SRC to DEST. */
data _null_;
length msg $ 384;
rc=fcopy('src', 'dest');
if rc=0 then
put 'Copied SRC to DEST.';
else do;
msg=sysmsg();
put rc= msg=;
end;
run;
INFO:The source fileref SRC for the FCOPY function is:Filename=your-source-file, RECFM=V,LRECL=32767,File Size (bytes)=121, Last Modified=15Aug2012:11:21:39, Create Time=15Aug2012:09:13:38 INFO:The destination fileref DEST for the FCOPY function is:Filename=your-destination-file, RECFM=V,LRECL=32767,File Size (bytes)=0, Last Modified=15Aug2012:11:21:39, Create Time=15Aug2012:09:13:39 Copied SRC to DEST.
/* Set MSGLEVEL to I to write messages from FCOPY to the log. */ options msglevel=i; filename src 'raises.xlsx' recfm=n; filename dest 'raises-2012.xlsx' recfm=n; /* Create an example file to copy. */ data _null_; file src; do i=1, 2105, 300312, 400501; put i:words256.; end; run; data _null_; length msg $ 384; rc=fcopy('src', 'dest'); if rc=0 then put 'Copied SRC to DEST.'; else do; msg=sysmsg(); put rc= msg=; end; run;
INFO:The source fileref SRC for the FCOPY function is:Filename=your-source-file, RECFM=N,LRECL=256,File Size (bytes)=117, Last Modified=15Aug2012:12:49:18, Create Time=15Aug2012:12:42:00 INFO:The destination fileref DEST for the FCOPY function is:Filename=your-destination-file, RECFM=N,LRECL=256,File Size (bytes)=0, Last Modified=15Aug2012:12:49:18, Create Time=15Aug2012:12:42:01 Copied SRC to DEST.
filename src 'source.txt' lrecl=256; /* Create example file to copy. */ data _null_; file src; do i=1, 2105, 300312, 400501; put i:words256.; end; run; /* Make LRECL for DEST short, to force output truncation. */ filename dest 'destination.txt' lrecl=5; /* Set MSGLEVEL to I to write messages from FCOPY to the log. */ options msglevel=i; data _null_; rc=fcopy('src', 'dest'); run;
INFO:The source fileref SRC for the FCOPY function is:Filename=your-source-file, RECFM=V,LRECL=256,File Size (bytes)=121, Last Modified=15Aug2012:15:14:38, Create Time=15Aug2012:09:13:38 INFO:The destination fileref DEST for the FCOPY function is:Filename=your-destination-file, RECFM=V,LRECL=5,File Size (bytes)=0, Last Modified=15Aug2012:15:14:38, Create Time=15Aug2012:09:13:39 WARNING:3 records were truncated when the FCOPY function wrote to fileref DEST.WARNING:To prevent the truncation of records in future operations, you can increase amount of space needed to accomodate the records by using the LRECL= system option or the LRECL= option in the FILENAME statement.