Search notes:

SAS data step: file handling

Copying a file

With a combination of infile and file, a file can be copied within a data step.
%let cpDir = /share/home/tq84/sas/copyFile;
%put &=cpDir;

/* Using the x statement to create a file: */
x echo Line one>      &cpDir/orig.txt;
x echo Another line>> &cpDir/orig.txt;
x echo Third line>>   &cpDir/orig.txt;
x echo etc...>>       &cpDir/orig.txt;


/* Define filerefs for source and destination file: */
filename src "&cpDir/orig.txt";
filename dst "&cpDir/copy.txt";

/* Run the datastep to copy src to dst */
data _null_;
      infile  src;
      file    dst;
      input;
      put _infile_;
run;

/* Clear filerefs: */
filename src clear;
filename dst clear;
Github repository about-SAS, path: /programming/data-step/file/copy-file.sas
See also Bytewise copy of a file, put _infile_.

Index

Fatal error: Uncaught PDOException: SQLSTATE[HY000]: General error: 8 attempt to write a readonly database in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php:78 Stack trace: #0 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(78): PDOStatement->execute(Array) #1 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(30): insert_webrequest_('/notes/Companie...', 1745581747, '18.119.0.68', 'Mozilla/5.0 App...', NULL) #2 /home/httpd/vhosts/renenyffenegger.ch/httpsdocs/notes/Companies-Products/SAS/programming/data-step/file/index(66): insert_webrequest() #3 {main} thrown in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php on line 78