BookmarkSubscribeRSS Feed
polingjw
Quartz | Level 8
I just installed Office 2007 on my computer. Previously, when I ran any SAS program that wrote to a RTF destination, the file would be displayed in the SAS results viewer window. Now, the RTF file is automatically opened in Word 2007. Is there anything I can do to open the file in the result viewer window instead? This issue is becoming an annoyance because, before rerunning any program, I now need to close each open RTF document to avoid errors associated with the file being in use. Several times I've had programs run for over 20 minutes only to later discover that no output was created. When the file was displayed in the SAS results viewer window, I could just include a couple of dm statements in my code to close the open window before generating the RTF document.

Thanks in advance for any suggestions.
6 REPLIES 6
David_SAS
SAS Employee
I remember reading that Microsoft intentionally changed Word 2007 to have the behavior you describe. I did a quick Web search but didn't turn up the related technical note.

-- David Kelley, SAS
Cynthia_sas
SAS Super FREQ
Hi:
As long as Word is holding your RTF document open (which it does when it displays the document to you), you cannot overwrite the file name. This means that you must
1) explicitly close WORD when you're done looking at the intermediate RTF results if you plan to rerun the job with the same name -- this means remembering to do something at the Word end
2) give the file a unique name every time while you're testing this means doing something at the SAS end. You could use SAS macro variables to make the name unique. Something like this (I'm not a big fan of ':' from time() in the file name, so I use TRANSLATE to turn the : into _):
[pre]
%let timeval = %sysfunc(time(),time8.);
%let timeval = %sysfunc(translate(&timeval,_,:));
%put &timeval;

ods rtf file="c:\temp\myfile&sysdate9._&timeval..rtf";

proc print data=sashelp.class;
run;

ods rtf close;
[/pre]

And, as long as your submissions were at least 1 second apart, the name would be unique. If you do this while you're testing, it avoids the issue you describe. At the very end, when you're done testing, you can use a final, production name, instead of the testing name.

cynthia
polingjw
Quartz | Level 8
Thanks for the suggestions. I guess that this means that it is not possible to just use the SAS results viewer to look at the RTF document after Word 2007 is installed.

Just in case it will help anyone else, I've developed another way to work around the issue. I'm actually using DDE to open and then close the file before the ODS RTF statement. For example:

options noxsync noxwait;
x '"C:\rtf_doc.rtf"';
filename cls_word DDE 'winword|system';
data _null_;
file cls_word;
put "[FILECLOSE()]";
run;

ods rtf file="C:\rtf_doc.rtf";
...

Thanks again. Message was edited by: polingjw
johns576
Calcite | Level 5
I have been having this same problem since installing office 2007. I have several programs that I run weekly that produce dozens of ODS RTF and Excel reports. It is quite disruptive to have my current window switch to the RTF document or Excel to verify that I want to open the "incompatible format" file. I have found that if I go to Tools>Options>Preferences>Results and deselect the View results as they are generated option it will not produce the results as I run the report and will simply output to the destination folder.

What I have been looking for is a way to script a control of this preference into the programs that I run that produce multiple RTF/Excel files so that it will turn off and then turn back on at the end so that I can view other types of output using the internal html viewer as it is created. EDIT: The Excel files are not created through ODS but through the export procedure, though the result is the same of having files pop to the front of my screen with dialogue boxes.


Message was edited by: johns576
David_SAS
SAS Employee
johns576 says:

What I have been looking for is a way to script a control of this preference into the programs that I run that produce multiple RTF/Excel files so that it will turn off and then turn back on at the end so that I can view other types of output using the internal html viewer as it is created.

I recommend contacting Tech Support (using the link at the bottom of this page). They should be able to provide PROC REGISTRY code to toggle the internal browser. I believe that's what is needed, but they'll know for sure.

-- David Kelley, SAS
johns576
Calcite | Level 5
The answer here was strikingly easy. The response from Tech support was to wrap the code in:

ODS results off;

ODS results on;

Since my institution is using 9.1.3 I have to make sure that the internal results browser is closed at the beginning of the execution or the behavior will default to displaying the files as they are created.

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
  • 6 replies
  • 2615 views
  • 0 likes
  • 4 in conversation