BookmarkSubscribeRSS Feed
DmytroYermak
Lapis Lazuli | Level 10

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.

8 REPLIES 8
RM6
Obsidian | Level 7 RM6
Obsidian | Level 7
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;
DmytroYermak
Lapis Lazuli | Level 10

When you have attributes details, variables with fixed length.

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

Reeza
Super User

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

Kurt_Bremser
Super User

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.

DmytroYermak
Lapis Lazuli | Level 10
Thank you! Do you know "the tags that indicate tabular data"?
Kurt_Bremser
Super User

@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.

PGStats
Opal | Level 21

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
ballardw
Super User

@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.

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
  • 8 replies
  • 2645 views
  • 3 likes
  • 6 in conversation