CORE
mp_binarycopy.sas
Go to the documentation of this file.
1 
23 %macro mp_binarycopy(
24  inloc= /* full path and filename of the object to be copied */
25  ,outloc= /* full path and filename of object to be created */
26  ,inref=____in /* override default to use own filerefs */
27  ,outref=____out /* override default to use own filerefs */
28  );
29  /* these IN and OUT filerefs can point to anything */
30  %if &inref = ____in %then %do;
31  filename &inref &inloc lrecl=1048576 ;
32  %end;
33  %if &outref=____out %then %do;
34  filename &outref &outloc lrecl=1048576 ;
35  %end;
36 
37  /* copy the file byte-for-byte */
38  data _null_;
39  length filein 8 fileid 8;
40  filein = fopen("&inref",'I',1,'B');
41  fileid = fopen("&outref",'O',1,'B');
42  rec = '20'x;
43  do while(fread(filein)=0);
44  rc = fget(filein,rec,1);
45  rc = fput(fileid, rec);
46  rc =fwrite(fileid);
47  end;
48  rc = fclose(filein);
49  rc = fclose(fileid);
50  run;
51  %if &inref = ____in %then %do;
52  filename &inref clear;
53  %end;
54  %if &outref=____out %then %do;
55  filename &outref clear;
56  %end;
57 %mend;