Monday, January 30, 2012

Copy/Move Files using Data Step

I found this post on "The SAS Dummy" Blog by Chris Hemedinger. It is an example of how to copy and move files anywhere. Thank You Chris. I have found your blog very informative and helpful.


/* these IN and OUT filerefs can point to anything */
filename in "c:\dataIn\input.xlsx";
filename out "c:\dataOut\output.xlsx";

/* copy the file byte-for-byte */
data _null_;
length filein 8 fileid 8;
filein = fopen('in','I',1,'B');
fileid = fopen('out','O',1,'B');
rec = '20'x;
do while(fread(filein)=0);
rc = fget(filein,rec,1);
rc = fput(fileid, rec);
rc =fwrite(fileid);
end;
rc = fclose(filein);
rc = fclose(fileid);
run;

No comments:

Post a Comment