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
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.
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?
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.
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.
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:
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.
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:
Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.
Register today!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.
Select SAS Training centers are offering in-person courses. View upcoming courses for: