BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
RW9
Diamond | Level 26 RW9
Diamond | Level 26

Hi,

Probably something simple, but have tried the options and can't seem to get it working.  In a text file (RTF) I have some data fields with spaces in (asis=on from a proc report), looks like:

\pard\plain\intbl\sb0\sa0\ql\f1\fs18\cf1{Sometext {\line}

  More Text {\line}

    Even More Text\cell}

On an infile statement:

  length buffer $2000.;

  infile "S:\Temp\Rob\RTF\Current\FLT2504_DOSEA_L-0301-mh-rand.rtf" dsd missover lrecl=32767;

  input buffer $;

These blanks are removed.  Any thoughts on getting them to read in correctly?

1 ACCEPTED SOLUTION

Accepted Solutions
data_null__
Jade | Level 19

You need to use an INFORMAT that does not trim leading blanks.  Your INPUT BUFFER $; statement is using LIST input which you don't want. Looks like you want to read the whole line as a string.  I use $VARYING informat with the LENGTH= option for the length variable.  This is fine as long as LRECL is LE 32767 which I expect it will be for RTF.  I have not seen RTF with LRECL anywhere near that.

View solution in original post

3 REPLIES 3
LinusH
Tourmaline | Level 20

I have no isdea about the problem, attaching the rtf could help us test.

But why do you want to read an rtf created by SAS? Is this a rescue operation and the original data is not available?

Data never sleeps
data_null__
Jade | Level 19

You need to use an INFORMAT that does not trim leading blanks.  Your INPUT BUFFER $; statement is using LIST input which you don't want. Looks like you want to read the whole line as a string.  I use $VARYING informat with the LENGTH= option for the length variable.  This is fine as long as LRECL is LE 32767 which I expect it will be for RTF.  I have not seen RTF with LRECL anywhere near that.

RW9
Diamond | Level 26 RW9
Diamond | Level 26

Thanks, knew its was something simple like that.  Informat=$varying200. works fine.

In response to LinusH, thanks for your response, actually its an RTF parser, mainly for validation, but possibly for other things as well.

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
  • 473 views
  • 0 likes
  • 3 in conversation