Production Ready Macros for SAS Application Developers
https://github.com/sasjs/core
mp_binarycopy.sas File Reference

Copy any file using binary input / output streams. More...

Go to the source code of this file.

Detailed Description

Reads in a file byte by byte and writes it back out. Is an os-independent method to copy files. In case of naming collision, the default filerefs can be modified. Based on: https://stackoverflow.com/questions/13046116/using-sas-to-copy-a-text-file

  %mp_binarycopy(inloc="/home/me/blah.txt", outref=_webout)

To append to a file, use the mode option, eg:

filename tmp1 temp;
filename tmp2 temp;
data _null_;
  file tmp1;
  put 'stacking';
run;

%mp_binarycopy(inref=tmp1, outref=tmp2, mode=APPEND)
%mp_binarycopy(inref=tmp1, outref=tmp2, mode=APPEND)
Parameters
[in]inlocquoted "path/and/filename.ext" of the file to be copied
[out]outlocquoted "path/and/filename.ext" of the file to be created
[in]inref(____in) If provided, this fileref will take precedence over the inloc parameter
[out]outref(____in) If provided, this fileref will take precedence over the outloc parameter. It must already exist!
[in]mode(CREATE) Valid values:
  • CREATE - Create the file (even if it already exists)
  • APPEND - Append to the file (don't overwrite)
Returns
nothing
Version
9.2

Definition in file mp_binarycopy.sas.