Prev: Summing Rows
Next: Saving the SAS log
From: Murphy Choy on 5 Dec 2009 09:23 Hi, Use proc printto to redirect log to an external text file. ------Original Message------ From: Orin Richards Sender: SAS(r) Discussion To: SAS-L(a)LISTSERV.UGA.EDU Subject: Saving the SAS log Sent: Dec 5, 2009 10:21 PM Hi All, Is there a way to get sas to automatically save your log file. I know it can be done but have never done it before. Is there an option to set or is some macro needed to do this. Thanks for your help. Orin Sent from my BlackBerry Wireless Handheld -- Regards, Murphy Choy Certified Advanced Programmer for SAS V9 Certified Basic Programmer for SAS V9
From: Lou on 5 Dec 2009 10:47 Or use the ALTLOG option when starting SAS. Or run your program in batch. "Murphy Choy" <goladin(a)gmail.com> wrote in message news:1242969826-1260023024-cardhu_decombobulator_blackberry.rim.net-171302414-(a)bda019.bisx.prodap.on.blackberry... > Hi, > > Use proc printto to redirect log to an external text file. > > ------Original Message------ > From: Orin Richards > Sender: SAS(r) Discussion > To: SAS-L(a)LISTSERV.UGA.EDU > Subject: Saving the SAS log > Sent: Dec 5, 2009 10:21 PM > > Hi All, > Is there a way to get sas to automatically save your log file. I know it can be done but have never done it before. Is there an option to set or is some macro needed to do this. > Thanks for your help. > > Orin > > > Sent from my BlackBerry Wireless Handheld > > -- > Regards, > Murphy Choy > > Certified Advanced Programmer for SAS V9 > Certified Basic Programmer for SAS V9
From: Scott Barry on 5 Dec 2009 10:09 On Sat, 5 Dec 2009 14:23:47 +0000, Murphy Choy <goladin(a)GMAIL.COM> wrote: >Hi, > >Use proc printto to redirect log to an external text file. > >------Original Message------ >From: Orin Richards >Sender: SAS(r) Discussion >To: SAS-L(a)LISTSERV.UGA.EDU >Subject: Saving the SAS log >Sent: Dec 5, 2009 10:21 PM > >Hi All, > Is there a way to get sas to automatically save your log file. I know it can be done but have never done it before. Is there an option to set or is some macro needed to do this. >Thanks for your help. > >Orin > > >Sent from my BlackBerry Wireless Handheld > >-- >Regards, >Murphy Choy > >Certified Advanced Programmer for SAS V9 >Certified Basic Programmer for SAS V9 Also, look at the ALTLOG option to save a "copy" of the SAS log. Scott Barry SBBWorks, Inc.
From: "Kevin F. Spratt" on 6 Dec 2009 15:04 At 09:21 AM 12/5/2009, you wrote: >Hi All, > Is there a way to get sas to automatically save your log > file. I know it can be done but have never done it before. Is > there an option to set or is some macro needed to do this. >Thanks for your help. > >Orin Orin, I asked a question about clearing the results window in SAS a couple of days ago and in so doing provided a copy of the default display manager (DM) commands that I use that do what you wand and a lot more things that you should want, like automating saving your sas output and sas programs as well. I attach an annotated set of some of this code for your experimentation. Note that this code has been updated recently by incorporating the DM command needed to clear the results window when you use ODS statements to create RTF output, which can be useful for a number of reasons, such as wishing to cut a results table into a word document that looks good. As is usually the case, there are a lot of SAS-Lers out there that know a lot and are willing to share. My "basic" SAS code using Display Manager (DM) commands to automate storing The SAS log, output, program and, if you specify it, an ODS RTF version of the output. Some other basic stuff too, like adding dates to the outputed files, clearing log and output windows before starting the write new logs and output information deleting all work SAS data sets before the new program starts creating new ones, which often have the same names when I program. ######################################### DM 'LOG;CLEAR;OUT;CLEAR;ODSRESULTS;CLEAR;EDITOR;'; /* CLEARING LOG AND OUTPUT WINDOWS */ %PUT &SYSDATE &SYSTIME; /* PUT DATE & TIME AT TOP OF LOG */ * CREATE DATE MACRO VARIABLE TO EMBED IN APPROPRIATE FILE NAMES ; %LET DATE=%SYSFUNC(DATE(), DATE.); **********************************************************************; * MACRO VARIABLES THAT SPECIFIY PROGRAM NAME AND EXTENTION, NON SAS DATASOURCE AND TABLE/SHEET NAME LOCATION OF PROJECT (DRIVE AND DIRECTORIES ; %LET PNAME=FOLLOWTYPES; %LET EXT =01; /* by specifying ext I can specify the order in which programs were run */ %LET DRV =V:; /* drive where project will live */ %LET PRJ =\ORTHO\DHMC\GRANTS\Project1; /* director where project lives */ /* Note that the naming conventions below assume that a directory structure for the project has been created. This structure assumes a directory that described the project, for this example this directory is called project1 and is, itself a subdirectory under a \ORTHOS\DHMC\GRANTS Under this "Project" directory (Project1) I usually include the following subdirectories: PGM (WHERE MY PROGRAMS WILL BE SAVED (SEE fILENAME PGM BELOW) LOG (WHERE MY PROGRAM LOGS WILL BE SAVED (SEE FILENAME LOG BELOW) OUT (WHERE MY PROGRAM OUTPUT WILL BE SAVED (SEE FILENAME OUT BELOW). DAT (WHERE MY PERMANENT SAS DATA SETS (SAVE.SASDATE) WILL BE SAVED (SEE LIBNAME SAVE BELOW) FOR (WHERE A PROJECT SPECIFIC FORMAT LIBRARY WOULD BE CREATED (SEEL LIBNAME LIBRARY BELOW) DOC (WHERE WORD DOCUMENTS OR EXPORTED FILES THAT WILL GO INTO WORD DOCUMENTS ARE DIRECTED) I DON'T TYPE ALL OF THE STUFF IN, BUT RATHER HAVE A "DEFAULT PROGRAM" THAT I OPEN INTO THE EDITOR WINDOW WHEN I START A NEW PROGRAM AND CHANGE THE STUFF AT THE TOP TO REFLECT THE NATURE OF THE NEW PROJECT (i HAVE NOT INCLUDED PRGRAM COMMENT SECTION HERE) */ *********************************************************************; * setting up libname and filenames based on above macro variables that saving typing and makes specification of program log, output and pgm names simple; LIBNAME SAVE "&DRV&PRJ\DAT"; LIBNAME LIBRARY "&DRV&PRJ\FOR"; FILENAME LOG "&DRV&PRJ\LOG\&PNAME._&DATE..L01"; FILENAME OUT "&DRV&PRJ\OUT\&PNAME._&DATE..O01"; FILENAME PGM "&DRV&PRJ\PGM\&PNAME._&DATE..P01"; DM 'PGM;RECALL;FILE PGM REP;'; /* SAVING PROGRAM AS RUN */ OPTIONS LS=172 PS=85 PAGENO=1 NOCENTER formdlim='*' FMTSEARCH=(WORK LIBRARY.DCSFMT); *******************************************************************************; QUIT; TITLE ''; ; *******************************************************************************; PROC DATASETS LIBRARY=WORK KILL; * REMOVE ALL TEMPORARY (WORK) SAS DATASETS ; *******************************************************************************; 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; options orientation=portrait; *******************************************************************************; * SPECIFY LOCATION OF OUTPUT DATA SET; ODS RTF FILE= "&drv&prj\doc\&pname..&DATE..rtf"; *******************************************************************************; * WRITE SAS CODE HERE; ODS RTF CLOSE; RUN; QUIT; *******************************************************************************; DM 'LOG;FILE LOG REP;OUTPUT;FILE OUT REP;'; /* SAVING LOG AND OUTPUT SCREENS */ ______________________________________________________________________ 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(a)Dartmouth.Edu (e-mail) _______________________________________________________________________
From: rjf2 on 7 Dec 2009 09:26 > From: Orin Richards > Subject: Saving the SAS log > > Hi All, > Is there a way to get sas to automatically save your log > file. I know it can be done but have never done it before. > Is there an option to set or is some macro needed to do this. > Thanks for your help. > > Orin this page addresses the use of the command-line option altlog to save a copy of the job log from a batch submission http://www.sascommunity.org/wiki/Saving_sas_logs note: you can use the command line parameter log to direct your program logs to a folder as well as a filename. as noted, if you use proc PrintTo within your sas session then you can date-stamp the log name. Ron Fehd the macro maven CDC Atlanta GA USA RJF2 at cdc dot gov
|
Pages: 1 Prev: Summing Rows Next: Saving the SAS log |