0
votes

The basic trouble is in adding some common data to multiple text files. The output of a SAS program i wrote is many text files in a folder like 30 to 50 text files, now i have to add a mobile number at the top in each file. Right now i do this by manually copying the number and then opening the text files and then pasting the number. Can someone suggest me an alternative way to do this maybe a SAS program or something like that.

Thanks in advance.

1

1 Answers

0
votes

This program will add the first record to your file (there is no way to 'insert' a new record at the start, the file has to be rebuilt):

%let myfile=C:\temp\MyFile1.sas;
data _null_;
infile "&myfile" ; /* consider using lrecl option if wider than 256 chars */
file "&myfile.";
input; 
if _n_ = 1 then put 'Some Phone Number'; 
put _infile_; 
run;

See the answer to this question for how to get a list of the text files in your folder..