BookmarkSubscribeRSS Feed
nickb
Calcite | Level 5
I have been doing some research on how to read a RTF file into a SAS dataset and haven't found much at all. Does anyone have any advise on reading in RTF files?

Thanks
7 REPLIES 7
sbb
Lapis Lazuli | Level 10 sbb
Lapis Lazuli | Level 10
The SAS support http://support.sas.com/ website has a few SUGI/SGF conference papers and technical references on the topic - it will be a matter of user-coded DATA step processing to parse/read the RTF data lines, interpret the commands/data-strings and generate your desired SAS dataset and variables.

Scott Barry
SBBWorks, Inc.

Suggested Google advanced search arguments, this topic/post:

read rtf file site:sas.com

read external data site:sas.com

data step programming introduction site:sas.com Message was edited by: sbb
Cynthia_sas
SAS Super FREQ
Hi:
In addition to Scott's suggestion, I have had students do the following:
1) open the RTF file with Word
2) highlight and cut/copy the table in Word
3) paste the table into Excel
4) save the Excel file to an XLS file
5) read the Excel file with PROC IMPORT or the Libname Engine

I would imagine that the process can be automated with Office macros or VB scripts. Depending on the volume of RTF files to be read, if you have a lot of RTF files, then you might want to invest the energy in the DATA step approach.

cynthia
Ksharp
Super User
Hahahaha.....
That is a good idea.I learned it .
fd2010
Calcite | Level 5
Hi Cynthia,

Thank you for all your insightful postings. I guess that you may be working for SAS.

Is it possible for SAS to come up with a %rtfToSAS so we can just import the rtf tables back into SAS data sets?

Regards,
sbb
Lapis Lazuli | Level 10 sbb
Lapis Lazuli | Level 10
Not sure it would make sense for SAS Institute - have you considered the number of standards/versions?

http://en.wikipedia.org/wiki/Rich_Text_Format

Scott Barry
SBBWorks, Inc.
Cynthia_sas
SAS Super FREQ
Hi:
I agree with Scott -- it doesn't make sense to me for an "RTF2SAS" routine. For one thing, an RTF file is a document -- with TITLES and FOOTNOTES and procedure titles and possibly a TABLE of contents. What if there is a table that spans pages? What if there is a table with ancillary text as a caption??? What if there are 10 footnotes with information about outliers??? What if there is one table of people's names and ages and another table of people's names and addresses -- would those be 2 separate datasets?? I don't think there's a way to write a generic program to parse the RTF description of a document and turn any tables found in that document into a SAS dataset(s).

I know that several folks have worked on parsing RTF and Word XML files. I believe there was a reference to this paper:
http://www.pharmasug.org/cd/papers/TT/TT13.pdf

That might be one place to start if you are intent on having such a conversion available.

cynthia
deleted_user
Not applicable
Hi,

I have written a paper to convert .rtf files into sas datasets.

This paper will be presented in Pharmasug2010 next week.

Please check the online proceedings of PharmaSUG2010 in a week or two.

Regards

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!

Discussion stats
  • 7 replies
  • 5584 views
  • 0 likes
  • 6 in conversation