- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Posted 08-18-2010 08:50 AM
(3442 views)
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.
Thanks in advance for any suggestions.
6 REPLIES 6
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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
-- David Kelley, SAS
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
The answer here was strikingly easy. The response from Tech support was to wrap the code in:
ODS results off;
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.