I want to read a file and find the word “the” and introduce a line feed. i.e. find and replace the text ‘the’
to ‘/nthe’
Can you please help?
/*input.txt*/
Many a slip between the cup and the lip.
/*Required output*/
Many a slip between
the cup and
the lip.
/*sas datastep*/
data inp;
infile "c:/tmp/input.txt";
/*ADD LOGIC*/
infile "c:/tmp/output.txt";
run;
Already answered in comments, summarized as answer
There are several options to do a find and replace in SAS, I would suggest using tranwrd.
SAS interprets a linefeed as '0A'x.
For a carriage return you would use '0D'x.
So the solution for you would be :
test_txt =tranwrd(text,"the",cat('0A'x,"the"));