DATA Step, Macro, Functions and more

How to read rtf with SAS

Reply
Regular Contributor
Posts: 210

How to read rtf with SAS

Hi all,

 

I wanted to write a sas code which could have defined number of the cells(variables) in rtf report and the lengths of each cell. Could you please provide any recommendations/links.

 

Thank you.

Contributor RM6
Contributor
Posts: 24

Re: How to read rtf with SAS

Posted in reply to DmytroYermak
Hi,
When you have attributes details, variables with fixed length. you can read the input raw data with fixed column input.
example:
data x;
infile "filename.rtf";
input Name $ 1-20
DOB $ 21-31
Gender $ 32
Balance 33-40;
run;
Regular Contributor
Posts: 210

Re: How to read rtf with SAS

When you have attributes details, variables with fixed length.

That is the question - I have just file and do not know the lengths.

Super User
Posts: 23,321

Re: How to read rtf with SAS

Posted in reply to DmytroYermak

@DmytroYermak you need to post more details of what you’re trying to do. 

Super User
Posts: 9,922

Re: How to read rtf with SAS

[ Edited ]
Posted in reply to DmytroYermak

RTF files are for word processor text. You need to scan the rtf text for tags that indicate tabular data, and then try to extract the cell values from that.

The wikipedia article on the rtf file format will give you hints how hard this will be.

RTF files are even less suited for SAS data input than Excel files.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
How to convert datasets to data steps
How to post code
Regular Contributor
Posts: 210

Re: How to read rtf with SAS

Posted in reply to KurtBremser
Thank you! Do you know "the tags that indicate tabular data"?
Super User
Posts: 9,922

Re: How to read rtf with SAS

Posted in reply to DmytroYermak

DmytroYermak wrote:
Thank you! Do you know "the tags that indicate tabular data"?

No. Best you can do is to create a rtf file with data as you expect it, and then inspect the contents of the file with a pure text editor.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
How to convert datasets to data steps
How to post code
Esteemed Advisor
Posts: 5,482

Re: How to read rtf with SAS

Posted in reply to DmytroYermak

For one shot deals, I can sometimes open the rtf file in Word, copy the material I want to the clipboard and then paste it into a raw text processor. Then read it from there with SAS.

PG
Super User
Posts: 13,338

Re: How to read rtf with SAS


PGStats wrote:

For one shot deals, I can sometimes open the rtf file in Word, copy the material I want to the clipboard and then paste it into a raw text processor. Then read it from there with SAS.


Or (shudders) paste into Excel. And save as CSV for import.

Ask a Question
Discussion stats
  • 8 replies
  • 325 views
  • 3 likes
  • 6 in conversation