You need to answer the question of how do you know which value to add to line 100 versus line 200.
If you have a text file with 1,000 lines and a dataset with 1,000 observations and want to match them one for one and create a new text file the basic logic could look like this.
So let's assume the original file is named 'original_file.txt' and you want to make a new file named 'new_file.txt' that adds the data from the variable NEW_VARIABLE in the dataset named NEW_DATA. If the file is a CSV file then the code could look like this:
data _null_;
infile 'original_file.txt' ;
file 'new_file.txt' ;
input ;
set new_data ;
put _infile_ ',' new_variable ;
run;
If the file has values in fixed locations then the PUT statement just need to change to indicate where on the line the new_variable's value is to be written. So perhaps the new value needs to start in column number 205.
put _infile_ @205 new_variable ;
... View more