SAS Programming

DATA Step, Macro, Functions and more
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

Special offer for SAS Communities members

Save $250 on SAS Innovate and get a free advance copy of the new SAS For Dummies book! Use the code "SASforDummies" to register. Don't miss out, May 6-9, in Orlando, Florida.

 

View the full agenda.

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