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

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

1 ACCEPTED SOLUTION

Accepted Solutions
RickDataX
Fluorite | Level 6

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

7 REPLIES 7
Reeza
Super User

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?

RickDataX
Fluorite | Level 6
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.
RickDataX
Fluorite | Level 6

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.

Reeza
Super User

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.

 

RickDataX
Fluorite | Level 6

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.

RickDataX
Fluorite | Level 6

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.

 

 

juliet_scott
Fluorite | Level 6

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.

 this is the best solution for SAS base exam preparation

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

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
  • 7 replies
  • 5760 views
  • 2 likes
  • 3 in conversation