BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Tal
Pyrite | Level 9 Tal
Pyrite | Level 9

Hi,

I have one external text file that i like to append to another but i dont like to read them in into a dataset as the files have many variables. And they both have the same layout. How do i do that?

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

Use your OS commands - in Unix its cat, may be in powershell as well.

Do you have headers you need to deal with or is it straight appending of the two text files.

View solution in original post

4 REPLIES 4
Reeza
Super User

Use your OS commands - in Unix its cat, may be in powershell as well.

Do you have headers you need to deal with or is it straight appending of the two text files.

Tal
Pyrite | Level 9 Tal
Pyrite | Level 9

Thx guys. The cat command works perfectly

BrunoMueller
SAS Super FREQ

You can make use of the MOD option of the FILE statement, this will allow you to add new records to an existing external file.

see this sample code, that illustrates this:

*
* create base file
*;

filename xbase temp;

data _null_;
 
set sashelp.class;
  where age lt 14;
 
file xbase dsd dlm=",";
 
put name age sex height weight;
run;

*
* create append file
*;

filename xapp temp;

data _null_;
 
set sashelp.class;
  where age ge 14;
 
file xapp dsd dlm=",";
 
put name age sex height weight;
run;

*
* use the base file with the MOD option, so
* that new reords are appended to the file
*;

data _null_;
 
file xbase mod;
 
infile xapp;
  input;
 
put _infile_;
run;

*
* verify the result
*;

data _null_;
 
infile xbase;
  input;
 
putlog _infile_;
run;

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 4 replies
  • 7277 views
  • 10 likes
  • 4 in conversation