Append records to an existing file in SAS1 min read

0 0 vote
Article Rating

The code illustrates how to append records to an existing file in SAS. It can be used to add text to the bottom of an existing file with the MOD option in the FILE statement.

The MOD option on the FILE statement is part of DATA step processing that is particularly used for appending to an existing file.

/* Create a csv file */
data _null_;
	infile datalines truncover;
	file "/home/9to5sas/examples/file.csv";
	input data :$10.;
	put data;
	datalines;
A
B
C
;
run;

/* Append information to the existing file using MOD option */
data _null_;
	file "/home/9to5sas/examples/file.csv" mod;
	input data :$10.;
	put data;
	datalines;
D
E
F
;
run;

 

Note the use of the PUT statement. PUT statement is used to write output to the SAS log. Here, it is used with the FILE statement to route this output to the same external file.

0 0 vote
Article Rating
Subscribe
Notify of
guest

This site uses Akismet to reduce spam. Learn how your comment data is processed.

0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x
Scroll to Top