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;

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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