BookmarkSubscribeRSS Feed
Hari2
Quartz | Level 8

Hi All,

 

I have one RTF file which has some data in it, Lets assume the file name is Test1.rtf.

Now through Proc Report I have to append data from a new dataset to the existing Test1.rtf.

 

please help me how can we do this. It should not overwrite the existing file.

3 REPLIES 3
Kurt_Bremser
Super User

RTF is a variant of "tagged" data, but different than HTML. So the existing file has a defined "end", and appending won't work. The word processor would stop reading as soon as it reaches the "end" mark of the initial file.

 

You can test this by opening a .rtf file with a standard text editor (notepad++), and appending all its contents a second time. When you open this with a word processor (I dit it with LibreOffice), you will only see the contents of the initial file. The "add-on" data is discarded.

 

You have two options:

#1: take the original data from which the RTF was created, append your current data, and create the file anew

#2: read the RTF as pure text, up to the "end" tag, and insert your new data (correctly tagged according to RTF norm), and add the end tag

 

#1 is to be preferred, of course.

RW9
Diamond | Level 26 RW9
Diamond | Level 26

That will prove to be very difficult.  RTF is a tagset based text file.  You can open it in Notepad or a text editor and see, there are numerous tags which tell the rendering program (Word for instance) how to use and display the data.  So first off you will need to know what all the tags are and how to work with them.  Then you can open the text file in a datastep, read it line by line until the point you want to insert, then go ahead and start writing out the data with all the associated tabs.  

I would really recommend you don't though as its an inordinate amount of work for little to no gain.  Is this a repeatable thing?  If so then get the datasets underlying the RTF, this is the best solution all round as you have the data and can do other things with it, you can also append your data and recreate the RTF.  

If it is a one off, then the simplest method would be to create and RTF with your data, then open the original in Word, and your one, copy and paste all your RTF output into the other in Word, then use Word to SaveAs RTF.  The output file will be slightly different from the SAS generated tagset, but will include both files.

The third option of doing it all yourself, well, good luck with that...

Patrick
Opal | Level 21

@Hari2

If you want to append output from a SAS program to an already existing .rft then that's going to be very difficult and not worth trying.

IF this is about creating a .rft with output from multiple steps out of the SAME program then this can be done. What's the case you're dealing with?

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
  • 3 replies
  • 1516 views
  • 2 likes
  • 4 in conversation