The SAS Output Delivery System and reporting techniques

SAS ODS RTF file corrupt

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 5
Accepted Solution

SAS ODS RTF file corrupt

SAS ODS RTF files occasionally are corrupt when creating multiple RTF files within a macro loop.  In the present study, I am creating an rtf document of tables for each subject.  I subset the data and run the macro loop for each subject with and ods rtf file open at start of loop and close at the end. I have 125 subjects but have to run in smaller groups of subjects because an occasional random rtf file is created but corrupted.  I can sometimes get up to about 20 or so rtf files created before a corrupt one is generated, but sometimes only a few. It seems random, and not always the same subject. Normal size for most of the subject rtf outputs are about 500k, but the corrupted file is about 1/2 the size.

 

I thought at first that McAfee live scan was touching it.  The problem occurs even if i turn off virus scan and turn off internet. 

 

I am running SAS 9.4 on Windows 7 pro laptop with 16 mb memory.

 

Has anyone seen the same problem, and know of a fix?

 

Thanks,

 

Rick Smith


Accepted Solutions
Solution
‎07-12-2016 03:22 PM
Occasional Contributor
Posts: 5

Re: SAS ODS RTF file corrupt

Solution:

 

It appears that SAS becomes a bit unstable for ods rtf documents when many rtf in-line commands are used.  Occasionally an rtf is created that is corrupt.  I did the following to correct the problem and allow all 125 rtf documents to be created without corrupt rtf and log errors.

 

1. I increased available memory for SAS from the default 2G to 4G or 6G. Copy the sasv9.cfg to another directory, edit it to add

-memsize 6G

-memmaxsz 6g

 

save, then edit the desktop shortcut to point to that location for the config file.

 

2. Recode to reduce the number of inline formatting commands, and special symbols.  I had used 'alt 255' for the hard-coded blank, which appeared to be fine in ods rtf text= statements but caused a problem when used within the cell of a table. Also the use of too many ~\ rtf commands were a problem. Too many changes in font sizes within a single ods rtf text= statement sometimes caused a problem. 

 

By reducing the number of rtf inline commands (multiples within same line), special symbols, and the increase in memory allowed SAS to become stable enough to output all 125 large patient report RTF files.

 

 

View solution in original post


All Replies
Grand Advisor
Posts: 17,338

Re: SAS ODS RTF file corrupt

Are you using custom RTF tags in your code anywhere?

Does your text have any potential symbols or characters that could interfere with RTF.

Have you tried ods rtf tagset?

Occasional Contributor
Posts: 5

Re: SAS ODS RTF file corrupt

I do use some rtf code in some of the tables.

I have tried ods tagset.rtf but I need a constant title in the header area, and footnote area so need the nobodytitle option so am using ods rtf.

The problem occurs randomly and when I rerun the same group, a different rtf is corrupted.
Occasional Contributor
Posts: 5

Re: SAS ODS RTF file corrupt

I do use some rtf formatting code in some of the tables.

 

I tried ods tagsets.rtf but need title and footnote in the header and footnote area so needed nobodytitle, so used ods rtf.

 

The problem is random. If the problem occurs and I run it again, then a different subject rtf output may be corrupted.

Grand Advisor
Posts: 17,338

Re: SAS ODS RTF file corrupt

Do you pause your process between runs? Try adding in a 2 second pause between file creations and see if that helps. I've had a similar issue with Excel files and that usually fixes it.

 

data _null_;
call sleep(2, 1);
run;

I'm assuming you don't have view results as generated on, so you're not seeing the files pop up as they run as well.

 

Occasional Contributor
Posts: 5

Re: SAS ODS RTF file corrupt

I've already added a 2 second sleep between runs, sometimes in several additional locations but no effect. I have no results pop up, only file to a folder. I also have the log going to a file instead of the log window.

Solution
‎07-12-2016 03:22 PM
Occasional Contributor
Posts: 5

Re: SAS ODS RTF file corrupt

Solution:

 

It appears that SAS becomes a bit unstable for ods rtf documents when many rtf in-line commands are used.  Occasionally an rtf is created that is corrupt.  I did the following to correct the problem and allow all 125 rtf documents to be created without corrupt rtf and log errors.

 

1. I increased available memory for SAS from the default 2G to 4G or 6G. Copy the sasv9.cfg to another directory, edit it to add

-memsize 6G

-memmaxsz 6g

 

save, then edit the desktop shortcut to point to that location for the config file.

 

2. Recode to reduce the number of inline formatting commands, and special symbols.  I had used 'alt 255' for the hard-coded blank, which appeared to be fine in ods rtf text= statements but caused a problem when used within the cell of a table. Also the use of too many ~\ rtf commands were a problem. Too many changes in font sizes within a single ods rtf text= statement sometimes caused a problem. 

 

By reducing the number of rtf inline commands (multiples within same line), special symbols, and the increase in memory allowed SAS to become stable enough to output all 125 large patient report RTF files.

 

 

New Contributor
Posts: 2

Re: SAS ODS RTF file corrupt

[ Edited ]

We create a RTF file in our desired path. We apply a style available in the styles library. We can see the output file in the mentioned path and we can download it to save in an environment different from the SAS environment. Please note that we have two proc SQL statements and both their output is captured into a single file.

 

ODS RTF
FILE=’/folders/myfolders/sasuser.v94/TutorialsPoint/CARS.rtf’
STYLE=EGDefault;
proc SQL;
select make, model, invoice
from sashelp.cars
where make in (‘Audi’,’BMW’)
and type = ‘Sports’
;
quit;

proc SQL;
select make,mean(horsepower)as meanhp
from sashelp.cars
where make in (‘Audi’,’BMW’)
group by make;
quit;

 

ODS rtf CLOSE;

 

When the above code is executed we get the following result:

 

ods_rtf_output.jpg

☑ This topic is SOLVED.

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

Discussion stats
  • 7 replies
  • 606 views
  • 2 likes
  • 3 in conversation