Below the ==== is a SAS program structure that I use for most programs.
I use DM or Display Manager commands to do a lot of things that I, in
my everyday work flow, cannot always be trusted to do.
Most of the DM commands below are commented for those who don't use
them and, after seeing the "magic" decide to try it out.
The purpose of this post, however, is to touch on one problem I have
with these commands when I am also using ODS statements to create RTF output.
In the program below I have commented out the ODS lines. As the program is
now, when you run the code, the DM commands all work. Logs and outputs
are cleared for any previous run and the program, log and output files
are all automatically saved with the names and extensions I have chosen, etc.
If you remove the comments, the results window does not clear with the DM
command, presumably, because the results now include calls to allow the
user to open the RTF output file using word.
My question is what can I do with DM or some other automated procedure to
get the results window to clear between programs when ODS statements have
been run in the previous program that create RTF files that can be viewed
by "clicking" on the file within the results window?
I'm currently running SAS 9.2 unders Windows XP-64, but these problems
were also obsereved in earlier versions of SAS and in 32-bit windows
environments.
self contained program follows: Note for it to work you need
to create on your c drive a directory off your root call Test under
which you must
also create L0G, DAT, OUT, PGM, FOR, AND DOC subdirectories. I
create this directory
and subdirectory structure for each project (although not off of my
c: root drive) as
it allows me to keep all things in a project all within an
encapsulated directory
==============================================================================
DM 'LOG;CLEAR;OUT;CLEAR;RESULTS CLEAR'; /* CLEARING LOG AND OUTPUT
WINDOWS */
%PUT &SYSDATE &SYSTIME; /* PUT DATE & TIME AT TOP OF
LOG */
******************************************************************************;
******************************************************************************;
%LET DATE=%SYSFUNC(DATE(),
DATE.);
%LET DRV =c:; /* drive where project is located
*/
%LET PRJ =\test; /* assumes a directory that has dat, for,
pgm, log, doc, and out subdirectories */
******************************************************************************;
%LET PNAME=pgm2; /* program name
*/
%LET EXT =01; /* program name extension, usually reflecting
version */
******************************************************************************;
LIBNAME SAVE "&DRV&PRJ\DAT"; /* sas permanent dataset
location */
LIBNAME LIBRARY "&DRV&PRJ\FOR"; /* location of format
library if created */
FILENAME LOG "&DRV&PRJ\LOG\&PNAME..&DATE..L&EXT"; /* log
saved here */
FILENAME OUT "&DRV&PRJ\OUT\&PNAME..&DATE..O&EXT"; /* output
saved here */
FILENAME PGM "&DRV&PRJ\PGM\&PNAME..&DATE..P&EXT"; /* pgm
saves here */
DM 'PGM;RECALL;FILE PGM REP;'; /* SAVING PROGRAM AS RUN
*/
OPTIONS LS=172 PS=85 PAGENO=1 NOCENTER FORMDLIM='*' MPRINT
SPOOL;
******************************************************************************;
QUIT;
TITLE '
';
******************************************************************************;
PROC DATASETS LIBRARY=WORK KILL; * REMOVE ALL TEMPORARY (WORK) SAS
DATASETS ;
RUN;
******************************************************************************;
* set up customized style
sheet;
ods path
work.myTmp(update)
sashelp.tmplmst(read)
;
proc
template;
define style
mystyle;
parent=styles.default;
replace fonts /
'TitleFont2' = ("Times
Roman",8pt)
'TitleFont' = ("Times
Roman",8pt)
'StrongFont' = ("Times
Roman",8pt)
'EmphasisFont' = ("Times
Roman",8pt)
'FixedEmphasisFont' = ("Times
Roman",8pt)
'FixedStrongFont' = ("Times
Roman",8pt)
'FixedHeadingFont' = ("Times
Roman",8pt)
'BatchFixedFont' = ("Times
Roman",8pt)
'FixedFont' = ("Times
Roman",8pt)
'headingEmphasisFont' = ("Times
Roman",8pt)
'headingFont' = ("Times
Roman",8pt)
'docFont' = ("Times
Roman",8pt);
end;
run;
**************************************************************************;
* specify the file location and type for ods
output;
* ODS RTF FILE=
"&DRV&PRJ\DOC\&PNAME..&DATE..RTF" style=mystyle;
**************************************************************************;
**************************************************************************;
data
work.one;
input a b
c;
cards;
1 2
3
1 1
1
1 2
1
;
run;
proc print
data=work.one;
run;
quit;
* ODS RTF
CLOSE;
*************************************************************************************;
*************************************************************************************;
DM 'LOG;FILE LOG REP;OUTPUT;FILE OUT REP;'; /* SAVING LOG AND
OUTPUT window results */
______________________________________________________________________
Kevin F. Spratt, Ph.D.
Department of Orthopaedic Surgery
Dartmouth Medical School
One Medical Center Drive
DHMC
Lebanon, NH USA 03756
(603) 653-6012 (voice)
(603) 653-6013 (fax)
Kevin.F.Spratt@Dartmouth.Edu (e-mail)
_______________________________________________________________________
|
|
0
|
|
|
|
Reply
|
Kevin
|
12/3/2009 8:29:16 PM |
|
Kevin,
I think that the command(s) you are looking for can be found in the
thread at:
http://www.listserv.uga.edu/cgi-bin/wa?A2=ind0310c&L=sas-l&P=35375
HTH,
Art
---------
On Dec 3, 3:29 pm, Kevin.F.Spr...@DARTMOUTH.EDU ("Kevin F. Spratt")
wrote:
> Below the ==== is a SAS program structure that I use for most programs.
>
> I use DM or Display Manager commands to do a lot of things that I, in
> my everyday work flow, cannot always be trusted to do.
>
> Most of the DM commands below are commented for those who don't use
> them and, after seeing the "magic" decide to try it out.
>
> The purpose of this post, however, is to touch on one problem I have
> with these commands when I am also using ODS statements to create RTF output.
>
> In the program below I have commented out the ODS lines. As the program is
> now, when you run the code, the DM commands all work. Logs and outputs
> are cleared for any previous run and the program, log and output files
> are all automatically saved with the names and extensions I have chosen, etc.
>
> If you remove the comments, the results window does not clear with the DM
> command, presumably, because the results now include calls to allow the
> user to open the RTF output file using word.
>
> My question is what can I do with DM or some other automated procedure to
> get the results window to clear between programs when ODS statements have
> been run in the previous program that create RTF files that can be viewed
> by "clicking" on the file within the results window?
>
> I'm currently running SAS 9.2 unders Windows XP-64, but these problems
> were also obsereved in earlier versions of SAS and in 32-bit windows
> environments.
>
> self contained program follows: Note for it to work you need
> to create on your c drive a directory off your root call Test under
> which you must
> also create L0G, DAT, OUT, PGM, FOR, AND DOC subdirectories. I
> create this directory
> and subdirectory structure for each project (although not off of my
> c: root drive) as
> it allows me to keep all things in a project all within an
> encapsulated directory
>
> ===========================================================================�===
>
> DM 'LOG;CLEAR;OUT;CLEAR;RESULTS CLEAR'; /* CLEARING LOG AND OUTPUT
> WINDOWS */
>
> %PUT &SYSDATE &SYSTIME; /* PUT DATE & TIME AT TOP OF
> LOG */
>
> ***************************************************************************�***;
>
> ***************************************************************************�***;
>
> %LET DATE=%SYSFUNC(DATE(),
> DATE.);
>
> %LET DRV =c:; /* drive where project is located
> */
> %LET PRJ =\test; /* assumes a directory that has dat, for,
> pgm, log, doc, and out subdirectories */
>
> ***************************************************************************�***;
>
> %LET PNAME=pgm2; /* program name
> */
>
> %LET EXT =01; /* program name extension, usually reflecting
> version */
>
> ***************************************************************************�***;
>
> LIBNAME SAVE "&DRV&PRJ\DAT"; /* sas permanent dataset
> location */
> LIBNAME LIBRARY "&DRV&PRJ\FOR"; /* location of format
> library if created */
>
> FILENAME LOG "&DRV&PRJ\LOG\&PNAME..&DATE..L&EXT"; /* log
> saved here */
> FILENAME OUT "&DRV&PRJ\OUT\&PNAME..&DATE..O&EXT"; /* output
> saved here */
> FILENAME PGM "&DRV&PRJ\PGM\&PNAME..&DATE..P&EXT"; /* pgm
> saves here */
>
> DM 'PGM;RECALL;FILE PGM REP;'; /* SAVING PROGRAM AS RUN
> */
>
> OPTIONS LS=172 PS=85 PAGENO=1 NOCENTER FORMDLIM='*' MPRINT
> SPOOL;
>
> ***************************************************************************�***;
>
> QUIT;
>
> TITLE '
> ';
>
> ***************************************************************************�***;
>
> PROC DATASETS LIBRARY=WORK KILL; * REMOVE ALL TEMPORARY (WORK) SAS
> DATASETS ;
> RUN;
>
> ***************************************************************************�***;
>
> * set up customized style
> sheet;
>
> ods path
> work.myTmp(update)
>
> sashelp.tmplmst(read)
>
> ;
>
> proc
> template;
>
> define style
> mystyle;
>
> parent=styles.default;
>
> replace fonts /
>
> 'TitleFont2' = ("Times
> Roman",8pt)
>
> 'TitleFont' = ("Times
> Roman",8pt)
>
> 'StrongFont' = ("Times
> Roman",8pt)
>
> 'EmphasisFont' = ("Times
> Roman",8pt)
>
> 'FixedEmphasisFont' = ("Times
> Roman",8pt)
>
> 'FixedStrongFont' = ("Times
> Roman",8pt)
>
> 'FixedHeadingFont' = ("Times
> Roman",8pt)
>
> 'BatchFixedFont' = ("Times
> Roman",8pt)
>
> 'FixedFont' = ("Times
> Roman",8pt)
>
> 'headingEmphasisFont' = ("Times
> Roman",8pt)
>
> 'headingFont' = ("Times
> Roman",8pt)
>
> 'docFont' = ("Times
> Roman",8pt);
>
> end;
>
> run;
>
> **************************************************************************;
>
> * specify the file location and type for ods
> output;
>
> * ODS RTF FILE=
> "&DRV&PRJ\DOC\&PNAME..&DATE..RTF" style=mystyle;
>
> **************************************************************************;
>
> **************************************************************************;
>
> data
> work.one;
>
> input a b
> c;
>
> cards;
>
> 1 2
> 3
>
> 1 1
> 1
>
> 1 2
> 1
>
> ;
>
> run;
>
> proc print
> data=work.one;
>
> run;
>
> quit;
>
> * ODS RTF
> CLOSE;
>
> ***************************************************************************�**********;
>
> ***************************************************************************�**********;
>
> DM 'LOG;FILE LOG REP;OUTPUT;FILE OUT REP;'; /* SAVING LOG AND
> OUTPUT window results */
>
> ______________________________________________________________________
>
> Kevin F. Spratt, Ph.D.
> Department of Orthopaedic Surgery
> Dartmouth Medical School
> One Medical Center Drive
> DHMC
> Lebanon, NH USA 03756
> (603) 653-6012 (voice)
> (603) 653-6013 (fax)
> Kevin.F.Spr...@Dartmouth.Edu (e-mail)
> _______________________________________________________________________
|
|
0
|
|
|
|
Reply
|
art297 (4237)
|
12/4/2009 12:02:48 AM
|
|
|
1 Replies
351 Views
(page loaded in 0.039 seconds)
|