BookmarkSubscribeRSS Feed
Michael_W
Calcite | Level 5
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?
2 REPLIES 2
sbb
Lapis Lazuli | Level 10 sbb
Lapis Lazuli | Level 10
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.
Michael_W
Calcite | Level 5
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; */

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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.

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
  • 2 replies
  • 1037 views
  • 0 likes
  • 2 in conversation