Date: Wed, 11 May 2005 13:36:51 -0500
Reply-To: "Workman, Rob" <Rob.Workman@SORIN-NA.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: "Workman, Rob" <Rob.Workman@SORIN-NA.COM>
Subject: Re: SAS -> MSWord DDE problems
Content-Type: text/plain; charset="us-ascii"
It may help to reduce the lrecl length on the filename statement.
Check out sas note: SN-010719:
http://support.sas.com/techsup/unotes/SN/010/010719.html
Memory is not freed and will incrementally decrease when you use DDE
with the FILENAME statement. For example,
FILENAME whatever DDE 'exceltriplet' lrecl=1000000;
Each time this code is submitted, the memory available decreases
by one megabyte or the amount specified by the LRECL.
This problem is fixed in SAS 9 where the buffer is only allocated
one time but that memory buffer is held until the end of the
session.
Kind regards,
Rob Workman
-----Original Message-----
From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of
Bross, Dean S
Sent: Wednesday, May 11, 2005 1:18 PM
To: SAS-L@LISTSERV.UGA.EDU
Subject: Re: SAS -> MSWord DDE problems
I have encountered exactly this occurrence for a number of years when
using WORD with DDE and have never been able to solve it. I think I
began having this problem when I switched to WORD 97 from WORD 95, but
the problem may have been there even earlier even though I didn't detect
it. I still have this problem today, and that is why I am switching one
application from DDE to using a combination of ODS RTF to write the
basic information into a document, followed by visual basic macros
running under WORD to complete the formation of the final document.
The problem seems to happen to me just as it happened to you, primarily
when you have transmitted many DDE commands. In your case, it looks
like you sent over 10,000 DDE commands before the system blew up.
Here are a couple of possible ways to reduce the problem. I don't know
if they work or how well they will work but they may have some
beneficial effect.
Break up the series of document commands by including a limited number
in one data step. Then stop that data step and put in a data step with
a sleep call for a few seconds. Then send some more DDE commands in a
subsequent data step.
Do you do a lot if InsertPicture commands. I can't prove it but these
seem to leak memory and may eventually cause problems.
See if there are a lot of other tasks running on your machine, and
terminate as many unnecessary ones as possible. You can reboot your
machine after the DDE run has finished and get them all back. I've
noticed that having more memory available can let you get more DDE
commands through before you hit a problem.
If things really get desperate and you have to use extensive DDE
commands in this application, you might try sending a limited number of
DDE commands and then saving the document with a DDE command and then
have WORD end its execution with a DDE command. Then, after a delay,
use the X command to start up WORD again.
Use a DDE command to reload the document and pick up where you left off.
It
appears to me that once WORD exits, it cleans up a lot of the problems
and gives you a fresh start. This is really a desperation measure since
the application will run very slowly, taking extra time to exit and then
reinitialize.
Maybe there are other people with a few other tricks. I have no idea
why this problem happens or how to get a real solution to it.
Dean Bross
-----Original Message-----
From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of
Howard Cherniack
Sent: Wednesday, May 11, 2005 3:20 AM
To: SAS-L@LISTSERV.UGA.EDU
Subject: SAS -> MSWord DDE problems
Like many others, we want to create some reports and put them into
MSWord form. After a great deal of unsuccessful wrestling with ODS,
MSWord's wonky NUMPAGES field, and incompatibilities between PROC REPORT
and ODS-RTF, I came across William Viergever's "Against All ODS"
(http://www2.sas.com/proceedings/sugi28/016-28.pdf), which describes how
to use old-fashioned DDE and WordBasic to control an MSWord document
from within SAS.
So I constructed a fairly elaborate superstructure that spins off report
lines to a text file, reads them into a SAS dataset, counts the pages
(for the "Page x of y" footer, which, it seems, no version of MSWord
gets right), creates an MSWord document, punches the report lines into
it, sets up headers and footers, saves the document, and closes Word and
the DDE link. Generally works pretty well, although it's a bit
time-consuming and has the annoying habit of popping up Word and messing
up the window focus (bringing up Word as minimized tends to result in
hangs.)
This works well, as I say, except for one particular, large,
report--about 198 pages. At one point about 80% of the way through,
everything stops (with the document open in Word), with the SAS-log
messages:
ERROR: DDE session not ready.
FATAL: Unrecoverable I/O error detected in the execution of the data
step program. Aborted during the EXECUTION phase.
NOTE: 10914 records were written to the file WINWORD.
Hmm. This happened several times, bombing out on the same line each
time. I looked at the lines around the place where the error
occurred--nothing very interesting there. I chopped a thousand lines off
the input dataset and tried again: this time, the report again aborted
at 10914 records (of course starting a little bit down the report, and
going on a bit farther). The "records" "written" to DDE are mostly
WordBasic commands and report text--there are just about 5700 lines in
the input file. I don't think that I have any other reports as big, but
I intend to generate some big reports with test lines.
Googling the error message seems to bring up only a couple of instances
where a SAS DDE connection to MSExcel bombs out with some sort of XML
problem or something. The MS Support site doesn't seem to have heard
about it. I know that DDE and WordBasic are pretty arcane in this day
and age, but I'd sure be grateful if anyone has any suggestions about
what the problem, or solution, might be. Many thanks, --Howard
----------------------------------------------------------------------------------------------
This message contains confidential information intended only for the use of the addressee(s).
If you are not the addressee, or the person responsible for delivering it to the addressee, you
are hereby notified that reading, disseminating, distributing or copying this message is strictly
prohibited. If you have received this message by mistake, please notify us, by replying to the
sender, and delete the original message immediately thereafter. Thank you.