BookmarkSubscribeRSS Feed
Yurie
Fluorite | Level 6

Hello, everyone

 

I have four variables start with {rtf1\.... symbols/text that I need to find some key words from there to generate a report. The contents include such as:

 

"{\rtf1\ansi\deff0\deftab720{\fonttbl{\f0\fswiss MS Sans Serif;}{\f1\froman\fcharset2 Symbol;}{\f2\froman Times New Roman;}{\f3\froman\fprq2 Times New Roman;}{\f4\fswiss MS Shell Dlg;}{\f5\froman Times New Roman;}{\f6\fswiss\fprq2 System;}}

{\colortbl\red0\green0\blue0;\red255\green0\blue0;}

\deflang1033\pard\plain\f5\fs20

}"

 

"{\rtf1\ansi\ansicpg1252\deff0\deftab720{\fonttbl{\f0\fswiss MS Sans Serif;}{\f1\froman\fcharset2 Symbol;}{\f2\froman Times New Roman;}{\f3\froman Times New Roman;}{\f4\fswiss\fprq2 System;}{\f5\froman\fprq2 Times New Roman;}}

{\colortbl\red0\green0\blue0;}

\deflang1033\pard\plain\f3\fs20

}"

 

"{\rtf1\ansi\ansicpg1252\deff0\deflang1033{\fonttbl{\f0\fnil\fcharset0 Times New Roman;}}

\viewkind4\uc1\pard\f0\fs20\par

}"

 

I do not know what are these symbols/text mean. I need to convert these text/symbols to plain text, so that I can search for the key words that I need.  Any suggestions/hints will be very appreciated! Thank you. 

 

3 REPLIES 3
Patrick
Opal | Level 21

Looks like you've read in some Word RTF document. How did you get there in first place?

 

I would try to first extract the text only with non-SAS tools and only then use SAS for further processing. How to do this depends on your environment.

 

You could for example use a VB script for extracting the text or also Tika does a really great job. https://tika.apache.org/download.html 

 

Yurie
Fluorite | Level 6

Hello, Patrick

 

I just use SAS with ODBC connecttion to get the data (it's Oracle database). My connection code showing below:

 

libname
exports 
Oracle
path =  XXX
dbprompt = no
uid=&username.
Password=&pswd.
schema = XXX
;

 

I tried to connect the data with excel, access and I got all the same text messages. I will check the link that you provided here soon. Thank you! 

Patrick
Opal | Level 21

Oh... I see. So that's stored in a CLOB in Oracle. That's gonna be tricky.

 

I've never been in your situation so can't speak out of experience. Just throwing some thoughts:

- Everything I've proposed in my last post assumed that you have direct access to the RTF document as a file; but that's not the case

- You would need to read the CLOB into multiple rows in SAS as a SAS variable can only hold 32KB. It's possible to do but needs some extra coding.

- There must be a reason that someone stores the RTF's in Oracle. If you're just after something like number of hits for a search term then may be there is Oracle Text available and you could run your queries in-database and then just get the result back. I've never used Oracle Text so not sure how and if this could be called out of a remote SAS process.

 

What I would try first:

Make things work directly in-database (using SQL developer; using Oracle Text). Only once things work try and call it out of a SAS session.

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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