The SAS Output Delivery System and reporting techniques

Post Processing an RTF File to Remove Control Words

Reply
Occasional Contributor
Posts: 18

Post Processing an RTF File to Remove Control Words

I am trying to post-process an RTF file to remore a couple of blank lines. I read in the RTF file using an INFILE statement and delete the two rows containing the RTF control words that are causing it to include the extra two blank lines. I've tried several approaches to writing the file back out to RTF and nothing seems to work. When I go to open the outputted file, Word gives me the following message: Word cannont read the formatting in this document. The same error occurs even if I do not remove the two blank lines.

When I open the original file with NotePad and then manually remove the same to lines, save it and then re-open with Word ...it works fine. When I visually compare the orginal file to the SAS-generated file I notice that SAS removes all of the blank lines (probably soft carriage returns) ..otherwise the two files look identical.

Any ideas on how I can achieve my objective?
Super Contributor
Super Contributor
Posts: 3,174

Re: Post Processing an RTF File to Remove Control Words

Share the code you are executing, preferably as part of a SAS log (pasted in your post reply). Without seeing your code, its guess work figuring out your problem.

Scott Barry
SBBWorks, Inc.
Occasional Contributor
Posts: 18

Re: Post Processing an RTF File to Remove Control Words

I think I have figured out what I needed to do to accomplish my objective. I borrowed and adapted the snippet of code from a SUGI paper: http://www2.sas.com/proceedings/sugi31/066-31.pdf

data InRTF;
infile "path\filename.rtf" missover length = l end = lastobs lrecl = 2000;
input line $varying2000. l;
line=tranwrd(line, '{\field{\*\fldinst SYMBOL 179 \\f "Symbol" }}', '>=');
line=tranwrd(line, '{\super a} ' , '');
if _n_=55 or _n_=56 then delete;
run;

data _null_;
file "path\filename.rtf" dsd;
set InRTF ;
put line;
run; */
Ask a Question
Discussion stats
  • 2 replies
  • 233 views
  • 0 likes
  • 2 in conversation