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

hello  ..  i need to create the following layout  ..

i would appreciate a solution on how to export append to an existing .txt file

GerdaNaude_0-1596621221447.png

thanks in advance

Gerda

1 ACCEPTED SOLUTION

Accepted Solutions
Tom
Super User Tom
Super User

Please provide more context on what you are actually doing.

But the answer is the MOD option on the FILE statement.  It looks like your example photograph has three types of records. So write them with three data steps.  The first one excludes the MOD option and will remove any existing file and start a new one. The others use the MOD option and append to the existing file.

data _null_;
  file 'myfile.txt' dsd dlm='|';
  set have1;
  put (_all_) (+0);
run;
data _null_;
  file 'myfile.txt' dsd dlm='|' mod;
  set have2;
  put (_all_) (+0);
run;
data _null_;
  file 'myfile.txt' dsd dlm='|' mod;
  set have3;
  put (_all_) (+0);
run;

 

View solution in original post

4 REPLIES 4
Tom
Super User Tom
Super User

Please provide more context on what you are actually doing.

But the answer is the MOD option on the FILE statement.  It looks like your example photograph has three types of records. So write them with three data steps.  The first one excludes the MOD option and will remove any existing file and start a new one. The others use the MOD option and append to the existing file.

data _null_;
  file 'myfile.txt' dsd dlm='|';
  set have1;
  put (_all_) (+0);
run;
data _null_;
  file 'myfile.txt' dsd dlm='|' mod;
  set have2;
  put (_all_) (+0);
run;
data _null_;
  file 'myfile.txt' dsd dlm='|' mod;
  set have3;
  put (_all_) (+0);
run;

 

GerdaNaude
Fluorite | Level 6
This is exactly what I’m looking for ..
I am very grateful .. thank you!

sas-innovate-white.png

Our biggest data and AI event of the year.

Don’t miss the livestream kicking off May 7. It’s free. It’s easy. And it’s the best seat in the house.

Join us virtually with our complimentary SAS Innovate Digital Pass. Watch live or on-demand in multiple languages, with translations available to help you get the most out of every session.

 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

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
  • 3538 views
  • 3 likes
  • 4 in conversation