Is there a SAS procedure / function which can be used to copy a text file from one location to another?
Of course this can be achieve using OS commands (%sysexec copy) but surely there must be an OS-agnostic way to do this?
From what I can tell by looking at the documentation, proc copy (or proc cport) only relate to SAS files..
The MOVEFILE function moves a file. The directory structure must already be in place for the function to move the file to its new location. If the target file already exists, the file is not moved and false is returned.
The simplest method is something like:
data _null_;
infile 'c:\input.txt';
file 'c:\output.txt';
input;
put _infile_;
run;
The method presented by RawFocus will copy any file, in binary, one byte at a time from input to output. For a text file this isn't necessary and doing the above will copy the file one line at a time. You may have to be slightly careful with record lengths, I believe that the default record length is 256, so you may need to put an explicit
lrecl=32767
option or similar on the infile
statement, as in
infile 'c:\input.txt' lrecl=32767;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With