DATA Step, Macro, Functions and more

How to output RTF file after using infile to read a RTF file

Accepted Solution Solved
Reply
Contributor
Posts: 36
Accepted Solution

How to output RTF file after using infile to read a RTF file

Hi SAS experts,

 

 I used Infile statement to read the attached file that was generated using 'ods rtf', then I tried to use 'ods rtf+proc report' to output it. The rtf files turns out to be like the snap as below. data _null_+file statement is the only method I tried that is able to generate the right output, but here I don't know how to define format, like font using data _null_+file statement. Thanks again for your help!

 

Input file:

data readrtf;
    infile "L16.4.1.rtf" missover length=len end=fin
        lrecl=2000 ;
    input string $varying2000. len;

run;

 

 

Method data _null_+file:

 

data _null_;
        file "&loc.\Compiled.rtf" lrecl=2000 mod;
    set readrtf;
    put string;
run;

 

method ods rtf+proc report:

 

ods rtf file='file.rtf';

proc report data=readrtf nowd;

column string;

define string;

run;

ods rtf close;

 

Capture.PNG

 


Accepted Solutions
Solution
‎05-26-2017 03:39 PM
Super User
Posts: 11,343

Re: How to output RTF file after using infile to read a RTF file

Posted in reply to fbl204653

So you are attempting to POST process rtf files and change something afterward? Was the original output done by SAS?

 

You may be more likely to have success with a Micro$oft VB macro. If you change the font outputing a data set like that with ODS you're only going to get an RTF document with a bunch of codes appearing with that font.

 

Or find the Font information buried in the raw rtf codes in that data _null_ search each line for the offending value and replace with the desired one. If you don't want to change every use of the font information then lots of luck with this approach.

 

If your original output was created by SAS then you may want to consider ensuring that the same style, style overides in procedures, or possibly create a custom style, is used to avoid that whole post process approach.

View solution in original post


All Replies
Super User
Posts: 11,343

Re: How to output RTF file after using infile to read a RTF file

Posted in reply to fbl204653

ODS RTF output is going to consider the text read into the SAS data set as character data that you want to show in the rtf document. Plus any of the report procs are going to add additional format based on the current style.

 

What is you are attempting to actually do?

File output with Put statements have NO information such as font type, size or color.

Contributor
Posts: 36

Re: How to output RTF file after using infile to read a RTF file

Thanks ballardw! What I tried to do is , compling several rtf files that are generated by 'ODS RTF'+'Proc Report' like L16.2.4.1, at the same time, format like font for each file has to be the same as orignal files.

Solution
‎05-26-2017 03:39 PM
Super User
Posts: 11,343

Re: How to output RTF file after using infile to read a RTF file

Posted in reply to fbl204653

So you are attempting to POST process rtf files and change something afterward? Was the original output done by SAS?

 

You may be more likely to have success with a Micro$oft VB macro. If you change the font outputing a data set like that with ODS you're only going to get an RTF document with a bunch of codes appearing with that font.

 

Or find the Font information buried in the raw rtf codes in that data _null_ search each line for the offending value and replace with the desired one. If you don't want to change every use of the font information then lots of luck with this approach.

 

If your original output was created by SAS then you may want to consider ensuring that the same style, style overides in procedures, or possibly create a custom style, is used to avoid that whole post process approach.

☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 3 replies
  • 143 views
  • 0 likes
  • 2 in conversation