Discussion:
What do you change to have a unique/numbered LOG/LST name?
(too old to reply)
Zack Haynes
2004-10-20 17:34:13 UTC
Permalink
Dear SAS-L;

What setup changes are needed to allow Win SAS
to create a unique .LOG and .LST file name for
the invoked SAS program. For example, a batch
file contains this command:
c:\sas\sas.exe c:\vssdev\saspgm1.sas

When above is executed SAS may create the following:
SASPGM1.LOG SASPGM1.LST

What I'd like to have:
SASPGM1.041020.132534.LOG SASPGM1.041020.132534.LST

Is this possible? We are using Win SAS 8.2. Thanks.

--
Zac Haynes, Systems & Applications Programmer, 714-404-8840.
ISPF Dialog, REXX, Scripts, SAS, Endevor, DB2, SQL, & Macro.

NOTE: THIS IS A CONFIDENTIAL COMMUNICATION. This transmission is intended
only for the use of the individuals or entity to which it is addressed. If
you are not the intended recipient, or the person responsible for delivering
the message to the intended recipient, please return or delete it
immediately. Although this e-mail and any attachments are believed to be
free of any virus or other defect, it is the responsibility of the recipient
to ensure that it is virus free and no responsibility is accepted by us for
any loss or damage arising in any way from its unauthorized modification or
use.
Fehd, Ronald J.
2004-10-20 18:10:54 UTC
Permalink
From: Zack Haynes
Dear SAS-L;
What setup changes are needed to allow Win SAS
to create a unique .LOG and .LST file name for
the invoked SAS program. For example, a batch
c:\sas\sas.exe c:\vssdev\saspgm1.sas
SASPGM1.LOG SASPGM1.LST
SASPGM1.041020.132534.LOG SASPGM1.041020.132534.LST
Is this possible? We are using Win SAS 8.2. Thanks.
Yes,
peripherally discussed or mentioned in passing in:
http://www.listserv.uga.edu/cgi-bin/wa?A2=ind0401B&L=sas-l&P=R4233

my macro AltCfg reads, updates and rewrites
a configuration file -- altlog.cfg -- that contains a file-specification
(path+filename.ext) for altlog and altprint

you asked for date-stamped
what I have that works produces a sequentially-numbered set of files
I'll have the date-stamped version in my book

this is no trivial undertaking, it involves:
* project.cfg
* altlog.cfg
* setting up access to site macro library

for latest version send e-mail with:
subject: request AltCfg.sas

Ron Fehd the macro maven CDC Atlanta GA USA
Jim Groeneveld
2004-10-22 13:14:41 UTC
Permalink
Hi Zack,

Try the following code:

======================================================================
DATA _NULL_;
Sysin = GETOPTION('Sysin');

LastBkSl = LENGTH ( Sysin ) - INDEX ( REVERSE ( TRIM ( Sysin ) ), '\' ) +
1;
FilePath = SUBSTR ( Sysin, 1, LastBkSl);

FileSpec = SCAN ( Sysin, -1, '\');
LastChar = LENGTH ( FileSpec ) - INDEX ( REVERSE ( TRIM (
FileSpec ) ), '.' );
FileName = SUBSTR ( FileSpec, 1, LastChar);

CurDate = COMPRESS ( PUT ( DATE(), YYMMDD10.), '-' );
CurTime = COMPRESS ( PUT ( TIME(), TIME. ), ':' );

FullSpec = TRIM(FilePath) || TRIM(FileName) || '.'
|| TRIM(CurDate) || '.' || TRIM(CurTime) || '.' ;
CALL SYMPUT ('FullSpec', TRIM(FullSpec));
RUN;

PROC PRINTTO LOG="&FullSpec.LOG" PRINT="&FullSpec.LST"; RUN;

* ......... your code .........;
======================================================================

Regards - Jim.
--
Y. (Jim) Groeneveld, MSc., Biostatistician, Science Team
Vitatron B.V., Meander 1051, 6825 MJ Arnhem
P.O.Box 5227, 6802 EE Arnhem, the Netherlands
Tel: +31/0 26 376 7365, Fax: +31/0 26 376 7305
Jim.Groeneveld_AT_Vitatron.com (replace _AT_ by AT sign)
http://www.vitatron.com, http://home.hccnet.nl/jim.groeneveld

My computer multi-boots OS's, each of them adapting the DST twice a year.

[common disclaimer]


On Wed, 20 Oct 2004 13:34:13 -0400, Zack Haynes
Post by Zack Haynes
Dear SAS-L;
What setup changes are needed to allow Win SAS
to create a unique .LOG and .LST file name for
the invoked SAS program. For example, a batch
c:\sas\sas.exe c:\vssdev\saspgm1.sas
SASPGM1.LOG SASPGM1.LST
SASPGM1.041020.132534.LOG SASPGM1.041020.132534.LST
Is this possible? We are using Win SAS 8.2. Thanks.
--
Zac Haynes, Systems & Applications Programmer, 714-404-8840.
ISPF Dialog, REXX, Scripts, SAS, Endevor, DB2, SQL, & Macro.
NOTE: THIS IS A CONFIDENTIAL COMMUNICATION. This transmission is intended
only for the use of the individuals or entity to which it is addressed. If
you are not the intended recipient, or the person responsible for
delivering
Post by Zack Haynes
the message to the intended recipient, please return or delete it
immediately. Although this e-mail and any attachments are believed to be
free of any virus or other defect, it is the responsibility of the
recipient
Post by Zack Haynes
to ensure that it is virus free and no responsibility is accepted by us for
any loss or damage arising in any way from its unauthorized modification or
use.
Fehd, Ronald J.
2004-10-22 14:37:03 UTC
Permalink
good solution, Jim
however, this will fail
if the job contains another PrintTo

- - - JobA - - -
*autoexec happens here;

Proc PrintTo log = "<&SysIn.&datestamp..log>";

.... some processing including use of:;
Proc PrintTo ...;
*this will disable the above date-stamp allocation;

Proc PrintTo;*end of log = "<&SysIn.&datestamp..log>";
- - - JobA end - - -

in my testing I saw that the only guaranteed way
to have a date-stamped log and list
was to allocate the filenames for altlog and altprint
in a configuration file

one method I developed in testing the date-stamped file-specs was:
- - - JobA.bat - - -
set JobName=JobA
sas -sysin DateStampAltLog -sysparm %JobName%
sas -config Project.cfg -sysin %JobName%
- - - JobA.bat end - - -

where altlog.cfg looks something like:
- - - altlog.cfg - - -
-altlog !ProjRoot\altlog\JobA20042960938.log
-altprint !ProjRoot\altlog\JobA20042960938.txt
- - - altlog.cfg end - - -
note the above date-stamp is hand-typed,
not the output of DateStampAltLog.sas

and
- - - Project.cfg - - -
-config u:\dls\SAS\sitev91.cfg /*calls SAShome/SASv9.cfg*/
-config altlog.cfg
-SET ProjRoot u:\DLS\ODTB\NTM\p2004_06
-SASinitialFolder !ProjRoot\pgm
- - - Project.cfg - - -

note that this writes the alt*.* to a separate folder

read the .sig
this replicates what I am doing in theory
but not exactly in practice

Ron Fehd the macro maven CDC Atlanta GA USA RJF2 at cdc dot gov

--> cheerful provider of UNTESTED SAS code from the Clue?Gee!Wrx <--
Jim Groeneveld
2004-10-25 14:49:13 UTC
Permalink
Hi Ron,

Now you'll get what you want. The following is an (initial) elaboration of
your and my ideas on how to enable a DateTimeStamp in log and print output
file names.

Short algorithm description
===========================
Log and print output files may be changed from within a SAS session using
PROC PRINTTO, but as Ron Fehd correctly pointed out, any subsequent use of
PROC PRINTTO, followed by a call to PROC PRINTTO to reset the output
streams to default (without LOG= and PRINT= specifications, or with their
resp. LOG and PRINT specifications), would not reset the destinations to
the DateTimeStamped file names. That only occurs if the specifications are
done at the time of SAS starting up, i.e. in the command line specification
of the -log and -print options. And that is what will be done.

Before running SAS batch with the specified program name as its -sysin
argument a program is run, which interpretes the [drive:][path\]filename
[.ext] specification of the program to run and generates DateTimeStamped
file specifications for both the log and print files. These file
specifications are specified while calling SAS with the program to run. The
initial program generating the DateTime Stamped file specifications could
be any program, written in any language, but here it is a SAS program,
which runs an initial instance of SAS batch.

The whole sequence of programs to run is called from a DOS batch file (i.e.
SASstamp.bat) (which may be found via the search PATH), that needs the
program [path and] name to run as its argument. This DOS script start SAS
with the just mentioned DateTimeStamping program (here [drive:][path\]
SASstamp.sas) as the -sysin argument and the program to run as the -sysparm
arugument. The SASstamp.sas program generates the DateTimeStamped file
names and a DOS command to call another batch file SAS8BAT.bat with a
similar syntax and explicit specifications for the log and print files. The
SASstamp.bat file itself suppresses its log and print output while
specifying 'nul' as their destinations.

Installation and adaptation
===========================
1. Put both DOS batch files SASstamp.bat and SAS8BAT.bat somewhere in your
search path, to be able to start them just by calling their name from
anywhere.
2. Put the SASstamp.sas program anywhere on your disk and adapt the DOS
batch file SASstamp.bat to contain the right path to SASstamp.sas .

Additional adaptations of DOS batch code may be necessary, dependent on SAS
and file locations and names. Possibly remove (comment out with REM) the
file existence check in the batch files.

Short directions for use
========================
Syntax: SASstamp <<program-name_to_run>> [other options]

Disclaimer
==========
The limited, but correctly working DOS batch language does not always seem
to be able to cope with long Windows file names, especially if containing
spaces and other exotic characters! The DOS batch files only have 9
variable parameters which may contain file name parts if (one or more)
embedded spaces are concerned, leaving too less registers for the
remaining, but very necessary arguments! Sticking to the 8.3 convention is
safest and works always correctly, deviations might work, but are not
guaranteed to work (correctly). This is where since the introduction of
Windows a rather limited, but consistent command language and its further
development has almost completely been neglected by MS, one of the lacks or
partial incompatibilities of Windows with DOS.

I have experimented with Windows95, Windows98, Windows2K, DOS command lines
and DOS batch files. A DOS command line has a limit of 127 characters
(after substituting environment variables). This limitation does not always
show from DOS batch files under Windows, but I'm not sure whether long
batch file lines always work correctly.

This strategy might be adapted for Unix (and possibly other platforms as
well). Unix (and Linux) scripts do not suffer from limitations as DOS batch
files do.

Well, this development is a preliminary one and may possibly be improved
and extended.


SASstamp.bat
============
@echo off
echo --- SASstamp.bat --- (C) Jim Groeneveld, 25 October 2004.
echo.
rem Date and time stamping log and print output and starts SAS in batch
mode.
if "%1"=="" goto Help
if not exist %1 goto NotExist (not guaranteed to always work correctly)

rem Switch to the drive the SAS_application is in:
%1\
rem Switch to the directory the SAS_application is in (to make it current):
cd %1\..
rem ...for use with options {ALT}LOG and {ALT}PRINT...
rem ...but these are redundant to specify the default drive/dir...
rem Otherwise the results are written to the drive/dir of this BATch file.

echo Starting SAS in batch mode. This window will disappear automatically.
start c:\Progra~1\SASIns~1\SAS\V8\sas -config c:\Progra~1\SASIns~1\SAS\V8
\sasv8.cfg -sysin y:\tmp\SASstamp.sas -sysparm %1 -log 'nul' -print 'nul' -
nosplash %2 %3 %4 %5 %6 %7 %8 %9
rem Adapt location of SASstamp.sas as desired.
goto End

:NotExist
echo File %1 does not exist!
echo.

:Help
echo Syntax from the DOS prompt: %0 «SAS_application_file»
echo ... or drag (in Windows) the SAS_application_icon to this
echo .BATch_file_icon (or its shortcut on the desktop).

pause
rem goto End

:End
----------


SASstamp.sas
============
OPTIONS NOXWAIT;

DATA _NULL_;
Sysparm = GETOPTION('Sysparm'); * may lack (partial) path specification;

FileSpec = SCAN ( Sysparm, -1, ':\');
IF (LENGTH ( Sysparm ) - LENGTH ( FileSpec ) GT 0) THEN
FilePath = SUBSTR ( Sysparm, 1, LENGTH ( Sysparm ) - LENGTH (
FileSpec ) );
ELSE FilePath = ''; * (because idiot SUBSTR does not allow 0 as 3rd arg);
LastChar = LENGTH ( FileSpec ) - INDEX ( REVERSE ( TRIM (
FileSpec ) ), '.' );
FileName = SUBSTR ( FileSpec, 1, LastChar);

CurDate = COMPRESS ( PUT ( DATE(), YYMMDD10.), '-' );
CurTime = COMPRESS ( PUT ( TIME(), TIME. ), ':' );

IF (FilePath NE '') THEN
FullSpec = TRIM(FilePath) || TRIM(FileName) || '.'
|| TRIM(CurDate) || '.' || TRIM(CurTime) || '.' ;
ELSE /* (because idiot empty string represents single, unwanted space) */
FullSpec = TRIM(FileName) || '.'
|| TRIM(CurDate) || '.' || TRIM(CurTime) || '.' ;

FullCmd = 'cmd /c Sas8bat "' || TRIM(Sysparm) || '" -log "' ||
TRIM(FullSpec) || 'log" -print "' ||
TRIM(FullSpec) || 'lst"' ;
CALL SYSTEM (TRIM(FullCmd));
RUN;

* SAS batch session terminates here; * another one is started via CALL
SYSTEM;
----------


SAS8BAT.bat
===========
@echo off
echo --- SASbatch.bat --- (C) Jim Groeneveld, 30 Oct 2001.
echo.
rem starts SAS in batch mode.
echo Feedback: %0 %1 %2 %3 %4 %5 %6 %7 %8 %9
if "%1"=="" goto Help
if not exist %1 goto NotExist (not guaranteed to always work correctly)

rem Switch to the drive the SAS_application is in:
%1\
rem Switch to the directory the SAS_application is in (to make it current):
cd %1\..
rem ...for use with options {ALT}LOG and {ALT}PRINT...
rem ...but these are redundant to specify the default drive/dir...
rem Otherwise the results are written to the drive/dir of this BATch file.

echo Starting SAS in batch mode. This window will disappear automatically.
start c:\Progra~1\SASIns~1\SAS\V8\sas -config c:\Progra~1\SASIns~1\SAS\V8
\sasv8.cfg -sysin %1 -nosplash %2 %3 %4 %5 %6 %7 %8 %9
goto End

:NotExist
echo File %1 does not exist!
echo.

:Help
echo Syntax from the DOS prompt: %0 «SAS_application_file»
echo ... or drag (in Windows) the SAS_application_icon to this
echo .BATch_file_icon (or its shortcut on the desktop).

rem Marking and clicking File in My Computer or Explorer and subsequently
rem clicking Batch Submit also yields the results in the drive/directory
rem of the application to run. Dit only applies to .SAS and .SS2 files.
rem Dragging the SAS_application_icon of some application to run to (the
rem shortcut of) SAS itself undesiredly results in the output on the
desktop.

pause
rem goto End

:End
----------


Regards - Jim.
--
Y. (Jim) Groeneveld, MSc., Biostatistician, Science Team
Vitatron B.V., Meander 1051, 6825 MJ Arnhem
P.O.Box 5227, 6802 EE Arnhem, the Netherlands
Tel: +31/0 26 376 7365, Fax: +31/0 26 376 7305
Jim.Groeneveld_AT_Vitatron.com (replace _AT_ by AT sign)
http://www.vitatron.com, http://home.hccnet.nl/jim.groeneveld

My computer multi-boots OS's, each of them adapting the DST twice a year.

[common disclaimer]

-----Original Message-----
From: SAS(r) Discussion [mailto:SAS-***@LISTSERV.UGA.EDU]On Behalf Of
Fehd, Ronald J.
Sent: Friday, October 22, 2004 16:37
To: SAS-***@LISTSERV.UGA.EDU
Subject: Re: What do you change to have a unique/numbered LOG/LST name?


good solution, Jim
however, this will fail
if the job contains another PrintTo

- - - JobA - - -
*autoexec happens here;

Proc PrintTo log = "<&SysIn.&datestamp..log>";

.... some processing including use of:;
Proc PrintTo ...;
*this will disable the above date-stamp allocation;

Proc PrintTo;*end of log = "<&SysIn.&datestamp..log>";
- - - JobA end - - -

in my testing I saw that the only guaranteed way
to have a date-stamped log and list
was to allocate the filenames for altlog and altprint
in a configuration file

one method I developed in testing the date-stamped file-specs was:
- - - JobA.bat - - -
set JobName=JobA
sas -sysin DateStampAltLog -sysparm %JobName%
sas -config Project.cfg -sysin %JobName%
- - - JobA.bat end - - -

where altlog.cfg looks something like:
- - - altlog.cfg - - -
-altlog !ProjRoot\altlog\JobA20042960938.log
-altprint !ProjRoot\altlog\JobA20042960938.txt
- - - altlog.cfg end - - -
note the above date-stamp is hand-typed,
not the output of DateStampAltLog.sas

and
- - - Project.cfg - - -
-config u:\dls\SAS\sitev91.cfg /*calls SAShome/SASv9.cfg*/
-config altlog.cfg
-SET ProjRoot u:\DLS\ODTB\NTM\p2004_06
-SASinitialFolder !ProjRoot\pgm
- - - Project.cfg - - -

note that this writes the alt*.* to a separate folder

read the .sig
this replicates what I am doing in theory
but not exactly in practice

Ron Fehd the macro maven CDC Atlanta GA USA RJF2 at cdc dot gov

--> cheerful provider of UNTESTED SAS code from the Clue?Gee!Wrx <--
Jim Groeneveld
2004-10-26 07:58:22 UTC
Permalink
Hi Ron,

Here is the first amendment on my DataTimeStamping code of yesterday:

After the line with
CurTime = COMPRESS ( PUT ( TIME(), TIME. ), ':' );
add a new line with
IF (SUBSTR(CurTime, 1, 1) EQ ' ') THEN SUBSTR(CurTime, 1, 1) = '0';

This is due to the fact that in the morning the resulting time starts with
a space. I don't see a more elegant, shorter solution. This way the time is
represented as hhmmss, where hh starts with a 0 if below 10.

Regards - Jim.
--
Y. (Jim) Groeneveld, MSc., Biostatistician, Science Team
Vitatron B.V., Meander 1051, 6825 MJ Arnhem
P.O.Box 5227, 6802 EE Arnhem, the Netherlands
Tel: +31/0 26 376 7365, Fax: +31/0 26 376 7305
Jim.Groeneveld_AT_Vitatron.com (replace _AT_ by AT sign)
http://www.vitatron.com, http://home.hccnet.nl/jim.groeneveld

My computer multi-boots OS's, each of them adapting the DST twice a year.

[common disclaimer]
Scott
2004-10-28 11:35:50 UTC
Permalink
If it were me, I'd give up on Windows' brain dead command interpretter,
install ActiveState PERL (free), pre-calculate the timestamp in the PERL
script, and invoke SAS with the -log and -print options. If this would be
an option for you, let me know and I can send you a sample PERL script that
does exactly what you want.

You can get PERL from http://www.activestate.com/Products/ActivePerl/
Post by Zack Haynes
Dear SAS-L;
What setup changes are needed to allow Win SAS
to create a unique .LOG and .LST file name for
the invoked SAS program. For example, a batch
c:\sas\sas.exe c:\vssdev\saspgm1.sas
SASPGM1.LOG SASPGM1.LST
SASPGM1.041020.132534.LOG SASPGM1.041020.132534.LST
Is this possible? We are using Win SAS 8.2. Thanks.
--
Zac Haynes, Systems & Applications Programmer, 714-404-8840.
ISPF Dialog, REXX, Scripts, SAS, Endevor, DB2, SQL, & Macro.
NOTE: THIS IS A CONFIDENTIAL COMMUNICATION. This transmission is intended
only for the use of the individuals or entity to which it is addressed. If
you are not the intended recipient, or the person responsible for delivering
the message to the intended recipient, please return or delete it
immediately. Although this e-mail and any attachments are believed to be
free of any virus or other defect, it is the responsibility of the recipient
to ensure that it is virus free and no responsibility is accepted by us for
any loss or damage arising in any way from its unauthorized modification or
use.
Jones Martyn
2004-10-28 12:06:32 UTC
Permalink
Why learn PERL when you've already got SAS? Execute SAS to build the bat
file to do what you want....

Schedule a .bat file containing....

"c:\Program Files\SAS Institute\SAS\V8\sas.exe" -autoexec
D:\Data\SASFiles\V8\batchautoexec.sas -sysin
D:\Data\SASFiles\V8\setbatchdailylog.sas"

Where setbatchdailylog.sas is ....

data _null_;
file 'd:/data/sasfiles/v8/batchdaily.bat';
format date date9. datec $9.;
date=today();
datec=put(date,date9.);
saslit='"c:\Program Files\SAS Institute\SAS\V8\sas.exe"';
autolit=' -autoexec D:\Data\SASFiles\V8\batchautoexec.sas';
sysinlit='-sysin D:\Data\SASFiles\V8\batchdaily.sas';
loglit='-log ' || 'D:\Data\SASFiles\V8\batchdaily'
||substr(datec,6,4)||substr(datec,3,3)
||substr(datec,1,2)||'.log';
put saslit autolit sysinlit loglit;
run;

And subsequently schedule 'd:/data/sasfiles/v8/batchdaily.bat'....

Martyn
-----Original Message-----
From: Scott [mailto:***@CRONKITE.CC.UGA.EDU]
Sent: 28 October 2004 12:36
To: SAS-***@LISTSERV.UGA.EDU
Subject: Re: What do you change to have a unique/numbered LOG/LST name?

If it were me, I'd give up on Windows' brain dead command interpretter,
install ActiveState PERL (free), pre-calculate the timestamp in the PERL
script, and invoke SAS with the -log and -print options. If this would be
an option for you, let me know and I can send you a sample PERL script that
does exactly what you want.

You can get PERL from http://www.activestate.com/Products/ActivePerl/
Post by Zack Haynes
Dear SAS-L;
What setup changes are needed to allow Win SAS
to create a unique .LOG and .LST file name for
the invoked SAS program. For example, a batch
c:\sas\sas.exe c:\vssdev\saspgm1.sas
SASPGM1.LOG SASPGM1.LST
SASPGM1.041020.132534.LOG SASPGM1.041020.132534.LST
Is this possible? We are using Win SAS 8.2. Thanks.
--
Zac Haynes, Systems & Applications Programmer, 714-404-8840.
ISPF Dialog, REXX, Scripts, SAS, Endevor, DB2, SQL, & Macro.
NOTE: THIS IS A CONFIDENTIAL COMMUNICATION. This transmission is intended
only for the use of the individuals or entity to which it is addressed. If
you are not the intended recipient, or the person responsible for
delivering
the message to the intended recipient, please return or delete it
immediately. Although this e-mail and any attachments are believed to be
free of any virus or other defect, it is the responsibility of the
recipient
to ensure that it is virus free and no responsibility is accepted by us
for
any loss or damage arising in any way from its unauthorized modification
or
use.
Scott
2004-11-01 02:09:16 UTC
Permalink
Look, I love SAS...really! I just think invoking SAS to create a batch file
to invoke SAS in batch, then scheduling both jobs, is not the best approach
for this problem. I would argue that, if the native Windows command
interpreter made it easy to capture and format the output of datetime, that
no here would suggest the below approach; they would say to just
pre-determine the log and lst file names, then invoke SAS appropriately. I
do agree that installing PERL and, to a lesser extent, learning PERL (not
much to learn in this scenario), could be an issue.

Here is a PERL script to do what Zac wants:

# Create a string as yymmdd.hhmmss, with zero leading padding
@datetime = localtime;
$dt = join '',
sprintf("%02d",$datetime[5]-100),
sprintf("%02d",$datetime[4]+1),
sprintf("%02d",$datetime[3]),
".",
sprintf("%02d",$datetime[2]),
sprintf("%02d",$datetime[1]),
sprintf("%02d",$datetime[0]); # this is yymmdd.hhmmss

# Where do you want to write the output files?
# Write them to the same path as where this PERL script is located
use Cwd;
$path = cwd();

# Invoke SAS
$cmd = "sas -nologo -icon -sysin \"$path/myprogram.sas\" -log
\"$path/myprogram.$dt.log\" -print \"$path/myprogram.$dt.lst\"";
print $cmd; # for debugging
system $cmd; # comment out during debugging, uncomment to execute
Post by Jones Martyn
Why learn PERL when you've already got SAS? Execute SAS to build the bat
file to do what you want....
Schedule a .bat file containing....
"c:\Program Files\SAS Institute\SAS\V8\sas.exe" -autoexec
D:\Data\SASFiles\V8\batchautoexec.sas -sysin
D:\Data\SASFiles\V8\setbatchdailylog.sas"
Where setbatchdailylog.sas is ....
data _null_;
file 'd:/data/sasfiles/v8/batchdaily.bat';
format date date9. datec $9.;
date=today();
datec=put(date,date9.);
saslit='"c:\Program Files\SAS Institute\SAS\V8\sas.exe"';
autolit=' -autoexec D:\Data\SASFiles\V8\batchautoexec.sas';
sysinlit='-sysin D:\Data\SASFiles\V8\batchdaily.sas';
loglit='-log ' || 'D:\Data\SASFiles\V8\batchdaily'
||substr(datec,6,4)||substr(datec,3,3)
||substr(datec,1,2)||'.log';
put saslit autolit sysinlit loglit;
run;
And subsequently schedule 'd:/data/sasfiles/v8/batchdaily.bat'....
Martyn
-----Original Message-----
Sent: 28 October 2004 12:36
Subject: Re: What do you change to have a unique/numbered LOG/LST name?
If it were me, I'd give up on Windows' brain dead command interpretter,
install ActiveState PERL (free), pre-calculate the timestamp in the PERL
script, and invoke SAS with the -log and -print options. If this would be
an option for you, let me know and I can send you a sample PERL script that
does exactly what you want.
You can get PERL from http://www.activestate.com/Products/ActivePerl/
Post by Zack Haynes
Dear SAS-L;
What setup changes are needed to allow Win SAS
to create a unique .LOG and .LST file name for
the invoked SAS program. For example, a batch
c:\sas\sas.exe c:\vssdev\saspgm1.sas
SASPGM1.LOG SASPGM1.LST
SASPGM1.041020.132534.LOG SASPGM1.041020.132534.LST
Is this possible? We are using Win SAS 8.2. Thanks.
--
Zac Haynes, Systems & Applications Programmer, 714-404-8840.
ISPF Dialog, REXX, Scripts, SAS, Endevor, DB2, SQL, & Macro.
NOTE: THIS IS A CONFIDENTIAL COMMUNICATION. This transmission is intended
only for the use of the individuals or entity to which it is addressed. If
you are not the intended recipient, or the person responsible for
delivering
the message to the intended recipient, please return or delete it
immediately. Although this e-mail and any attachments are believed to be
free of any virus or other defect, it is the responsibility of the
recipient
to ensure that it is virus free and no responsibility is accepted by us
for
any loss or damage arising in any way from its unauthorized modification
or
use.
Peter Crawford
2004-10-29 19:50:59 UTC
Permalink
I've been using sas to do this for my display manager sessions on win
playforms for >10 years !
Techniques have become simpler over the years
Last posted as %upalts, I expect you'll find it in the archives
Peter Crawford
On Thu, 28 Oct 2004 13:06:32 +0100, Jones Martyn
Post by Jones Martyn
Why learn PERL when you've already got SAS? Execute SAS to build the bat
file to do what you want....
Schedule a .bat file containing....
"c:\Program Files\SAS Institute\SAS\V8\sas.exe" -autoexec
D:\Data\SASFiles\V8\batchautoexec.sas -sysin
D:\Data\SASFiles\V8\setbatchdailylog.sas"
Where setbatchdailylog.sas is ....
data _null_;
file 'd:/data/sasfiles/v8/batchdaily.bat';
format date date9. datec $9.;
date=today();
datec=put(date,date9.);
saslit='"c:\Program Files\SAS Institute\SAS\V8\sas.exe"';
autolit=' -autoexec D:\Data\SASFiles\V8\batchautoexec.sas';
sysinlit='-sysin D:\Data\SASFiles\V8\batchdaily.sas';
loglit='-log ' || 'D:\Data\SASFiles\V8\batchdaily'
||substr(datec,6,4)||substr(datec,3,3)
||substr(datec,1,2)||'.log';
put saslit autolit sysinlit loglit;
run;
And subsequently schedule 'd:/data/sasfiles/v8/batchdaily.bat'....
Martyn
-----Original Message-----
Sent: 28 October 2004 12:36
Subject: Re: What do you change to have a unique/numbered LOG/LST name?
If it were me, I'd give up on Windows' brain dead command interpretter,
install ActiveState PERL (free), pre-calculate the timestamp in the PERL
script, and invoke SAS with the -log and -print options. If this would be
an option for you, let me know and I can send you a sample PERL script
that
Post by Jones Martyn
does exactly what you want.
You can get PERL from http://www.activestate.com/Products/ActivePerl/
Post by Zack Haynes
Dear SAS-L;
What setup changes are needed to allow Win SAS
to create a unique .LOG and .LST file name for
the invoked SAS program. For example, a batch
c:\sas\sas.exe c:\vssdev\saspgm1.sas
SASPGM1.LOG SASPGM1.LST
SASPGM1.041020.132534.LOG SASPGM1.041020.132534.LST
Is this possible? We are using Win SAS 8.2. Thanks.
--
Zac Haynes, Systems & Applications Programmer, 714-404-8840.
ISPF Dialog, REXX, Scripts, SAS, Endevor, DB2, SQL, & Macro.
NOTE: THIS IS A CONFIDENTIAL COMMUNICATION. This transmission is
intended
Post by Jones Martyn
Post by Zack Haynes
only for the use of the individuals or entity to which it is addressed.
If
Post by Jones Martyn
Post by Zack Haynes
you are not the intended recipient, or the person responsible for
delivering
the message to the intended recipient, please return or delete it
immediately. Although this e-mail and any attachments are believed to be
free of any virus or other defect, it is the responsibility of the
recipient
to ensure that it is virus free and no responsibility is accepted by us
for
any loss or damage arising in any way from its unauthorized modification
or
use.
Zack Haynes
2004-10-29 21:17:07 UTC
Permalink
Dear SAS-L;

Thanks to all for input on unique Log/Lst names. I would have
done the same as you've suggested with REXX or Script but a more
automatic SAS solution is required. Here is what I was hoping
to have as the required solution in a pseudo code, (not working)
where the SAS program is written and a batch file is used to
execute a SAS in batch which invokes your SAS program with the
Log/Lst options. You then only need to copy the batch model
YourSas.bat & change the SAS program name within it. Is it Ok
to call SAS within a SAS in this way? If so, what is the best
way to pass along 'YourSas.sas' program names? Thanks.

YourSas.bat:
SasBatch -sysparm? 'YourSas.sas'

SasBatch:
Data _null_ rundate=date() runtime=time()
call symputs for rundate runtime sysparm
%sysexec c:\sas\sas.exe &sysparm
-log &sysparm..&rundate..&runtime
-lst &sysparm..&rundate..&runtime
Result: YourSas.sas.041029.171323.log/lst

--
Zac Haynes, Systems & Applications Programmer, 714-404-8840.
ISPF Dialog, REXX, Scripts, SAS, Endevor, DB2, SQL, & Macro.


-----Original Message-----
From: SAS(r) Discussion [mailto:SAS-***@LISTSERV.UGA.EDU]On Behalf Of
Peter Crawford
Sent: Friday, October 29, 2004 3:51 PM
To: SAS-***@LISTSERV.UGA.EDU
Subject: Re: What do you change to have a unique/numbered LOG/LST name?


I've been using sas to do this for my display manager sessions on win
playforms for >10 years !
Techniques have become simpler over the years
Last posted as %upalts, I expect you'll find it in the archives
Peter Crawford
On Thu, 28 Oct 2004 13:06:32 +0100, Jones Martyn
Post by Jones Martyn
Why learn PERL when you've already got SAS? Execute SAS to build the bat
file to do what you want....
Schedule a .bat file containing....
"c:\Program Files\SAS Institute\SAS\V8\sas.exe" -autoexec
D:\Data\SASFiles\V8\batchautoexec.sas -sysin
D:\Data\SASFiles\V8\setbatchdailylog.sas"
Where setbatchdailylog.sas is ....
data _null_;
file 'd:/data/sasfiles/v8/batchdaily.bat';
format date date9. datec $9.;
date=today();
datec=put(date,date9.);
saslit='"c:\Program Files\SAS Institute\SAS\V8\sas.exe"';
autolit=' -autoexec D:\Data\SASFiles\V8\batchautoexec.sas';
sysinlit='-sysin D:\Data\SASFiles\V8\batchdaily.sas';
loglit='-log ' || 'D:\Data\SASFiles\V8\batchdaily'
||substr(datec,6,4)||substr(datec,3,3)
||substr(datec,1,2)||'.log';
put saslit autolit sysinlit loglit;
run;
And subsequently schedule 'd:/data/sasfiles/v8/batchdaily.bat'....
Martyn
-----Original Message-----
Sent: 28 October 2004 12:36
Subject: Re: What do you change to have a unique/numbered LOG/LST name?
If it were me, I'd give up on Windows' brain dead command interpretter,
install ActiveState PERL (free), pre-calculate the timestamp in the PERL
script, and invoke SAS with the -log and -print options. If this would be
an option for you, let me know and I can send you a sample PERL script
that
Post by Jones Martyn
does exactly what you want.
You can get PERL from http://www.activestate.com/Products/ActivePerl/
Post by Zack Haynes
Dear SAS-L;
What setup changes are needed to allow Win SAS
to create a unique .LOG and .LST file name for
the invoked SAS program. For example, a batch
c:\sas\sas.exe c:\vssdev\saspgm1.sas
SASPGM1.LOG SASPGM1.LST
SASPGM1.041020.132534.LOG SASPGM1.041020.132534.LST
Is this possible? We are using Win SAS 8.2. Thanks.
--
Zac Haynes, Systems & Applications Programmer, 714-404-8840.
ISPF Dialog, REXX, Scripts, SAS, Endevor, DB2, SQL, & Macro.
NOTE: THIS IS A CONFIDENTIAL COMMUNICATION. This transmission is
intended
Post by Jones Martyn
Post by Zack Haynes
only for the use of the individuals or entity to which it is addressed.
If
Post by Jones Martyn
Post by Zack Haynes
you are not the intended recipient, or the person responsible for
delivering
the message to the intended recipient, please return or delete it
immediately. Although this e-mail and any attachments are believed to be
free of any virus or other defect, it is the responsibility of the
recipient
to ensure that it is virus free and no responsibility is accepted by us
for
any loss or damage arising in any way from its unauthorized modification
or
use.
NOTE: THIS IS A CONFIDENTIAL COMMUNICATION. This transmission is intended
only for the use of the individuals or entity to which it is addressed. If
you are not the intended recipient, or the person responsible for delivering
the message to the intended recipient, please return or delete it
immediately. Although this e-mail and any attachments are believed to be
free of any virus or other defect, it is the responsibility of the recipient
to ensure that it is virus free and no responsibility is accepted by us for
any loss or damage arising in any way from its unauthorized modification or
use.
Jim Groeneveld
2004-10-30 21:46:26 UTC
Permalink
Hi Zack,

The solution I sent you (with an amandment) comes close to what you want.
If you just install (put) the files at their locations, all you have to do
to start your batch SAs program is to enter from a dos window:
SASstamp <<your SAS program>>
to get datime-stamped output and log files.
You could also create a shortcut (PIF) for SAS stamp:
[drive:][\subdirectory]SASstamp %1 %2 %3 %4 %5 %6 %7 %8 %9
to drag and drop your SAS program on (I think, I use the command line).

Or do you work interactively with SAS and want to start you batch program
from there? I would have to think of the changes to perform, but you might
invent them yourself as well.

Good luck.

Regards - Jim.

On Fri, 29 Oct 2004 17:17:07 -0400, Zack Haynes
Post by Zack Haynes
Dear SAS-L;
Thanks to all for input on unique Log/Lst names. I would have
done the same as you've suggested with REXX or Script but a more
automatic SAS solution is required. Here is what I was hoping
to have as the required solution in a pseudo code, (not working)
where the SAS program is written and a batch file is used to
execute a SAS in batch which invokes your SAS program with the
Log/Lst options. You then only need to copy the batch model
YourSas.bat & change the SAS program name within it. Is it Ok
to call SAS within a SAS in this way? If so, what is the best
way to pass along 'YourSas.sas' program names? Thanks.
SasBatch -sysparm? 'YourSas.sas'
Data _null_ rundate=date() runtime=time()
call symputs for rundate runtime sysparm
%sysexec c:\sas\sas.exe &sysparm
-log &sysparm..&rundate..&runtime
-lst &sysparm..&rundate..&runtime
Result: YourSas.sas.041029.171323.log/lst
--
Zac Haynes, Systems & Applications Programmer, 714-404-8840.
ISPF Dialog, REXX, Scripts, SAS, Endevor, DB2, SQL, & Macro.
-----Original Message-----
Peter Crawford
Sent: Friday, October 29, 2004 3:51 PM
Subject: Re: What do you change to have a unique/numbered LOG/LST name?
I've been using sas to do this for my display manager sessions on win
playforms for >10 years !
Techniques have become simpler over the years
Last posted as %upalts, I expect you'll find it in the archives
Peter Crawford
On Thu, 28 Oct 2004 13:06:32 +0100, Jones Martyn
Post by Jones Martyn
Why learn PERL when you've already got SAS? Execute SAS to build the bat
file to do what you want....
Schedule a .bat file containing....
"c:\Program Files\SAS Institute\SAS\V8\sas.exe" -autoexec
D:\Data\SASFiles\V8\batchautoexec.sas -sysin
D:\Data\SASFiles\V8\setbatchdailylog.sas"
Where setbatchdailylog.sas is ....
data _null_;
file 'd:/data/sasfiles/v8/batchdaily.bat';
format date date9. datec $9.;
date=today();
datec=put(date,date9.);
saslit='"c:\Program Files\SAS Institute\SAS\V8\sas.exe"';
autolit=' -autoexec D:\Data\SASFiles\V8\batchautoexec.sas';
sysinlit='-sysin D:\Data\SASFiles\V8\batchdaily.sas';
loglit='-log ' || 'D:\Data\SASFiles\V8\batchdaily'
||substr(datec,6,4)||substr(datec,3,3)
||substr(datec,1,2)||'.log';
put saslit autolit sysinlit loglit;
run;
And subsequently schedule 'd:/data/sasfiles/v8/batchdaily.bat'....
Martyn
-----Original Message-----
Sent: 28 October 2004 12:36
Subject: Re: What do you change to have a unique/numbered LOG/LST name?
If it were me, I'd give up on Windows' brain dead command interpretter,
install ActiveState PERL (free), pre-calculate the timestamp in the PERL
script, and invoke SAS with the -log and -print options. If this would be
an option for you, let me know and I can send you a sample PERL script
that
Post by Jones Martyn
does exactly what you want.
You can get PERL from http://www.activestate.com/Products/ActivePerl/
Post by Zack Haynes
Dear SAS-L;
What setup changes are needed to allow Win SAS
to create a unique .LOG and .LST file name for
the invoked SAS program. For example, a batch
c:\sas\sas.exe c:\vssdev\saspgm1.sas
SASPGM1.LOG SASPGM1.LST
SASPGM1.041020.132534.LOG SASPGM1.041020.132534.LST
Is this possible? We are using Win SAS 8.2. Thanks.
--
Zac Haynes, Systems & Applications Programmer, 714-404-8840.
ISPF Dialog, REXX, Scripts, SAS, Endevor, DB2, SQL, & Macro.
NOTE: THIS IS A CONFIDENTIAL COMMUNICATION. This transmission is
intended
Post by Jones Martyn
Post by Zack Haynes
only for the use of the individuals or entity to which it is addressed.
If
Post by Jones Martyn
Post by Zack Haynes
you are not the intended recipient, or the person responsible for
delivering
the message to the intended recipient, please return or delete it
immediately. Although this e-mail and any attachments are believed to be
free of any virus or other defect, it is the responsibility of the
recipient
to ensure that it is virus free and no responsibility is accepted by us
for
any loss or damage arising in any way from its unauthorized modification
or
use.
NOTE: THIS IS A CONFIDENTIAL COMMUNICATION. This transmission is intended
only for the use of the individuals or entity to which it is addressed. If
you are not the intended recipient, or the person responsible for
delivering
Post by Zack Haynes
the message to the intended recipient, please return or delete it
immediately. Although this e-mail and any attachments are believed to be
free of any virus or other defect, it is the responsibility of the
recipient
Post by Zack Haynes
to ensure that it is virus free and no responsibility is accepted by us for
any loss or damage arising in any way from its unauthorized modification or
use.
Jack Hamilton
2004-11-03 17:44:29 UTC
Permalink
It's pretty easy to capture the date in Windows NT (and above):

=====
@echo off
FOR /f "tokens=2-4 delims=/ " %%a in ('DATE/T') do SET
date=%%c-%%a-%%b
echo DATE is %DATE%
=====

prints

=====
DATE is 2004-11-03
=====

Just leave the dashes out of the FOR statement if you don't want them.

Time is more difficult. The TIME /T command prints only the hour and
minute, without seconds, and uses regional display settings, so you
can't be sure what you'll get back.

If you need the time, you could use the Windows Scripting Host (Visual
Basic or JScript) rather than a batch file. It comes with recent
versions of Windows.




--
***@FirstHealth.com
Manager, Technical Development
Metrics Department, First Health
West Sacramento, California USA
PM >>>
Look, I love SAS...really! I just think invoking SAS to create a batch
file
to invoke SAS in batch, then scheduling both jobs, is not the best
approach
for this problem. I would argue that, if the native Windows command
interpreter made it easy to capture and format the output of datetime,
that
no here would suggest the below approach; they would say to just
pre-determine the log and lst file names, then invoke SAS
appropriately. I
do agree that installing PERL and, to a lesser extent, learning PERL
(not
much to learn in this scenario), could be an issue.

Here is a PERL script to do what Zac wants:

# Create a string as yymmdd.hhmmss, with zero leading padding
@datetime = localtime;
$dt = join '',
sprintf("%02d",$datetime[5]-100),
sprintf("%02d",$datetime[4]+1),
sprintf("%02d",$datetime[3]),
".",
sprintf("%02d",$datetime[2]),
sprintf("%02d",$datetime[1]),
sprintf("%02d",$datetime[0]); # this is yymmdd.hhmmss

# Where do you want to write the output files?
# Write them to the same path as where this PERL script is located
use Cwd;
$path = cwd();

# Invoke SAS
$cmd = "sas -nologo -icon -sysin \"$path/myprogram.sas\" -log
\"$path/myprogram.$dt.log\" -print \"$path/myprogram.$dt.lst\"";
print $cmd; # for debugging
system $cmd; # comment out during debugging, uncomment to execute
Post by Jones Martyn
Why learn PERL when you've already got SAS? Execute SAS to build the
bat
Post by Jones Martyn
file to do what you want....
Schedule a .bat file containing....
"c:\Program Files\SAS Institute\SAS\V8\sas.exe" -autoexec
D:\Data\SASFiles\V8\batchautoexec.sas -sysin
D:\Data\SASFiles\V8\setbatchdailylog.sas"
Where setbatchdailylog.sas is ....
data _null_;
file 'd:/data/sasfiles/v8/batchdaily.bat';
format date date9. datec $9.;
date=today();
datec=put(date,date9.);
saslit='"c:\Program Files\SAS Institute\SAS\V8\sas.exe"';
autolit=' -autoexec D:\Data\SASFiles\V8\batchautoexec.sas';
sysinlit='-sysin D:\Data\SASFiles\V8\batchdaily.sas';
loglit='-log ' || 'D:\Data\SASFiles\V8\batchdaily'
||substr(datec,6,4)||substr(datec,3,3)
||substr(datec,1,2)||'.log';
put saslit autolit sysinlit loglit;
run;
And subsequently schedule 'd:/data/sasfiles/v8/batchdaily.bat'....
Martyn
-----Original Message-----
Sent: 28 October 2004 12:36
Subject: Re: What do you change to have a unique/numbered LOG/LST
name?
Post by Jones Martyn
If it were me, I'd give up on Windows' brain dead command
interpretter,
Post by Jones Martyn
install ActiveState PERL (free), pre-calculate the timestamp in the
PERL
Post by Jones Martyn
script, and invoke SAS with the -log and -print options. If this
would be
Post by Jones Martyn
an option for you, let me know and I can send you a sample PERL
script
Post by Jones Martyn
that
does exactly what you want.
You can get PERL from http://www.activestate.com/Products/ActivePerl/
Post by Zack Haynes
Dear SAS-L;
What setup changes are needed to allow Win SAS
to create a unique .LOG and .LST file name for
the invoked SAS program. For example, a batch
c:\sas\sas.exe c:\vssdev\saspgm1.sas
SASPGM1.LOG SASPGM1.LST
SASPGM1.041020.132534.LOG SASPGM1.041020.132534.LST
Is this possible? We are using Win SAS 8.2. Thanks.
--
Zac Haynes, Systems & Applications Programmer, 714-404-8840.
ISPF Dialog, REXX, Scripts, SAS, Endevor, DB2, SQL, & Macro.
NOTE: THIS IS A CONFIDENTIAL COMMUNICATION. This transmission is
intended
Post by Jones Martyn
Post by Zack Haynes
only for the use of the individuals or entity to which it is
addressed.
Post by Jones Martyn
Post by Zack Haynes
If
you are not the intended recipient, or the person responsible for
delivering
the message to the intended recipient, please return or delete it
immediately. Although this e-mail and any attachments are believed
to be
Post by Jones Martyn
Post by Zack Haynes
free of any virus or other defect, it is the responsibility of the
recipient
to ensure that it is virus free and no responsibility is accepted by
us
Post by Jones Martyn
Post by Zack Haynes
for
any loss or damage arising in any way from its unauthorized
modification
Post by Jones Martyn
Post by Zack Haynes
or
use.
Scott
2004-12-01 12:44:55 UTC
Permalink
On my system this returns 01-Dec-04 because of my regional settings. In
addition to PERL, cscript might be another (better?) solution that would
return the date independent of the regional settings.
Post by Jim Groeneveld
=====
@echo off
FOR /f "tokens=2-4 delims=/ " %%a in ('DATE/T') do SET
date=%%c-%%a-%%b
echo DATE is %DATE%
=====
prints
=====
DATE is 2004-11-03
=====
Just leave the dashes out of the FOR statement if you don't want them.
Time is more difficult. The TIME /T command prints only the hour and
minute, without seconds, and uses regional display settings, so you
can't be sure what you'll get back.
If you need the time, you could use the Windows Scripting Host (Visual
Basic or JScript) rather than a batch file. It comes with recent
versions of Windows.
--
Manager, Technical Development
Metrics Department, First Health
West Sacramento, California USA
PM >>>
Look, I love SAS...really! I just think invoking SAS to create a batch
file
to invoke SAS in batch, then scheduling both jobs, is not the best
approach
for this problem. I would argue that, if the native Windows command
interpreter made it easy to capture and format the output of datetime,
that
no here would suggest the below approach; they would say to just
pre-determine the log and lst file names, then invoke SAS
appropriately. I
do agree that installing PERL and, to a lesser extent, learning PERL
(not
much to learn in this scenario), could be an issue.
# Create a string as yymmdd.hhmmss, with zero leading padding
@datetime = localtime;
$dt = join '',
sprintf("%02d",$datetime[5]-100),
sprintf("%02d",$datetime[4]+1),
sprintf("%02d",$datetime[3]),
".",
sprintf("%02d",$datetime[2]),
sprintf("%02d",$datetime[1]),
sprintf("%02d",$datetime[0]); # this is yymmdd.hhmmss
# Where do you want to write the output files?
# Write them to the same path as where this PERL script is located
use Cwd;
$path = cwd();
# Invoke SAS
$cmd = "sas -nologo -icon -sysin \"$path/myprogram.sas\" -log
\"$path/myprogram.$dt.log\" -print \"$path/myprogram.$dt.lst\"";
print $cmd; # for debugging
system $cmd; # comment out during debugging, uncomment to execute
Post by Jones Martyn
Why learn PERL when you've already got SAS? Execute SAS to build the
bat
Post by Jones Martyn
file to do what you want....
Schedule a .bat file containing....
"c:\Program Files\SAS Institute\SAS\V8\sas.exe" -autoexec
D:\Data\SASFiles\V8\batchautoexec.sas -sysin
D:\Data\SASFiles\V8\setbatchdailylog.sas"
Where setbatchdailylog.sas is ....
data _null_;
file 'd:/data/sasfiles/v8/batchdaily.bat';
format date date9. datec $9.;
date=today();
datec=put(date,date9.);
saslit='"c:\Program Files\SAS Institute\SAS\V8\sas.exe"';
autolit=' -autoexec D:\Data\SASFiles\V8\batchautoexec.sas';
sysinlit='-sysin D:\Data\SASFiles\V8\batchdaily.sas';
loglit='-log ' || 'D:\Data\SASFiles\V8\batchdaily'
||substr(datec,6,4)||substr(datec,3,3)
||substr(datec,1,2)||'.log';
put saslit autolit sysinlit loglit;
run;
And subsequently schedule 'd:/data/sasfiles/v8/batchdaily.bat'....
Martyn
-----Original Message-----
Sent: 28 October 2004 12:36
Subject: Re: What do you change to have a unique/numbered LOG/LST
name?
Post by Jones Martyn
If it were me, I'd give up on Windows' brain dead command
interpretter,
Post by Jones Martyn
install ActiveState PERL (free), pre-calculate the timestamp in the
PERL
Post by Jones Martyn
script, and invoke SAS with the -log and -print options. If this
would be
Post by Jones Martyn
an option for you, let me know and I can send you a sample PERL
script
Post by Jones Martyn
that
does exactly what you want.
You can get PERL from http://www.activestate.com/Products/ActivePerl/
Post by Zack Haynes
Dear SAS-L;
What setup changes are needed to allow Win SAS
to create a unique .LOG and .LST file name for
the invoked SAS program. For example, a batch
c:\sas\sas.exe c:\vssdev\saspgm1.sas
SASPGM1.LOG SASPGM1.LST
SASPGM1.041020.132534.LOG SASPGM1.041020.132534.LST
Is this possible? We are using Win SAS 8.2. Thanks.
--
Zac Haynes, Systems & Applications Programmer, 714-404-8840.
ISPF Dialog, REXX, Scripts, SAS, Endevor, DB2, SQL, & Macro.
NOTE: THIS IS A CONFIDENTIAL COMMUNICATION. This transmission is
intended
Post by Jones Martyn
Post by Zack Haynes
only for the use of the individuals or entity to which it is
addressed.
Post by Jones Martyn
Post by Zack Haynes
If
you are not the intended recipient, or the person responsible for
delivering
the message to the intended recipient, please return or delete it
immediately. Although this e-mail and any attachments are believed
to be
Post by Jones Martyn
Post by Zack Haynes
free of any virus or other defect, it is the responsibility of the
recipient
to ensure that it is virus free and no responsibility is accepted by
us
Post by Jones Martyn
Post by Zack Haynes
for
any loss or damage arising in any way from its unauthorized
modification
Post by Jones Martyn
Post by Zack Haynes
or
use.
David L. Cassell
2004-12-01 21:02:36 UTC
Permalink
Post by Scott
On my system this returns 01-Dec-04 because of my regional settings.
In
Post by Scott
addition to PERL, cscript might be another (better?) solution that would
return the date independent of the regional settings.
BTW, that's Perl, not PERL.

Python would be another good choice. Tcl would work as well.

David
--
David Cassell, CSC
***@epa.gov
Senior computing specialist
mathematical statistician
Zack Haynes
2004-11-03 19:21:15 UTC
Permalink
Dear SAS-L;

Jack; Even still this approach is simple enough to be
an almost unavoidable solution. The original requirement
calls for a SAS language solution to create the date/time
but this is too easy. Thanks.

--
Zac Haynes, Systems & Applications Programmer, 714-404-8840.
ISPF Dialog, REXX, Scripts, SAS, Endevor, DB2, SQL, & Macro.


-----Original Message-----
From: SAS(r) Discussion [mailto:SAS-***@LISTSERV.UGA.EDU]On Behalf Of Jack
Hamilton
Sent: Wednesday, November 03, 2004 12:44 PM
To: SAS-***@LISTSERV.UGA.EDU
Subject: Re: What do you change to have a unique/numbered LOG/LST name?


It's pretty easy to capture the date in Windows NT (and above):

=====
@echo off
FOR /f "tokens=2-4 delims=/ " %%a in ('DATE/T') do SET
date=%%c-%%a-%%b
echo DATE is %DATE%
=====

prints

=====
DATE is 2004-11-03
=====

Just leave the dashes out of the FOR statement if you don't want them.

Time is more difficult. The TIME /T command prints only the hour and
minute, without seconds, and uses regional display settings, so you
can't be sure what you'll get back.

If you need the time, you could use the Windows Scripting Host (Visual
Basic or JScript) rather than a batch file. It comes with recent
versions of Windows.




--
***@FirstHealth.com
Manager, Technical Development
Metrics Department, First Health
West Sacramento, California USA
PM >>>
Look, I love SAS...really! I just think invoking SAS to create a batch
file
to invoke SAS in batch, then scheduling both jobs, is not the best
approach
for this problem. I would argue that, if the native Windows command
interpreter made it easy to capture and format the output of datetime,
that
no here would suggest the below approach; they would say to just
pre-determine the log and lst file names, then invoke SAS
appropriately. I
do agree that installing PERL and, to a lesser extent, learning PERL
(not
much to learn in this scenario), could be an issue.

Here is a PERL script to do what Zac wants:

# Create a string as yymmdd.hhmmss, with zero leading padding
@datetime = localtime;
$dt = join '',
sprintf("%02d",$datetime[5]-100),
sprintf("%02d",$datetime[4]+1),
sprintf("%02d",$datetime[3]),
".",
sprintf("%02d",$datetime[2]),
sprintf("%02d",$datetime[1]),
sprintf("%02d",$datetime[0]); # this is yymmdd.hhmmss

# Where do you want to write the output files?
# Write them to the same path as where this PERL script is located
use Cwd;
$path = cwd();

# Invoke SAS
$cmd = "sas -nologo -icon -sysin \"$path/myprogram.sas\" -log
\"$path/myprogram.$dt.log\" -print \"$path/myprogram.$dt.lst\"";
print $cmd; # for debugging
system $cmd; # comment out during debugging, uncomment to execute
Post by Jones Martyn
Why learn PERL when you've already got SAS? Execute SAS to build the
bat
Post by Jones Martyn
file to do what you want....
Schedule a .bat file containing....
"c:\Program Files\SAS Institute\SAS\V8\sas.exe" -autoexec
D:\Data\SASFiles\V8\batchautoexec.sas -sysin
D:\Data\SASFiles\V8\setbatchdailylog.sas"
Where setbatchdailylog.sas is ....
data _null_;
file 'd:/data/sasfiles/v8/batchdaily.bat';
format date date9. datec $9.;
date=today();
datec=put(date,date9.);
saslit='"c:\Program Files\SAS Institute\SAS\V8\sas.exe"';
autolit=' -autoexec D:\Data\SASFiles\V8\batchautoexec.sas';
sysinlit='-sysin D:\Data\SASFiles\V8\batchdaily.sas';
loglit='-log ' || 'D:\Data\SASFiles\V8\batchdaily'
||substr(datec,6,4)||substr(datec,3,3)
||substr(datec,1,2)||'.log';
put saslit autolit sysinlit loglit;
run;
And subsequently schedule 'd:/data/sasfiles/v8/batchdaily.bat'....
Martyn
-----Original Message-----
Sent: 28 October 2004 12:36
Subject: Re: What do you change to have a unique/numbered LOG/LST
name?
Post by Jones Martyn
If it were me, I'd give up on Windows' brain dead command
interpretter,
Post by Jones Martyn
install ActiveState PERL (free), pre-calculate the timestamp in the
PERL
Post by Jones Martyn
script, and invoke SAS with the -log and -print options. If this
would be
Post by Jones Martyn
an option for you, let me know and I can send you a sample PERL
script
Post by Jones Martyn
that
does exactly what you want.
You can get PERL from http://www.activestate.com/Products/ActivePerl/
Post by Zack Haynes
Dear SAS-L;
What setup changes are needed to allow Win SAS
to create a unique .LOG and .LST file name for
the invoked SAS program. For example, a batch
c:\sas\sas.exe c:\vssdev\saspgm1.sas
SASPGM1.LOG SASPGM1.LST
SASPGM1.041020.132534.LOG SASPGM1.041020.132534.LST
Is this possible? We are using Win SAS 8.2. Thanks.
--
Zac Haynes, Systems & Applications Programmer, 714-404-8840.
ISPF Dialog, REXX, Scripts, SAS, Endevor, DB2, SQL, & Macro.
NOTE: THIS IS A CONFIDENTIAL COMMUNICATION. This transmission is
intended
Post by Jones Martyn
Post by Zack Haynes
only for the use of the individuals or entity to which it is
addressed.
Post by Jones Martyn
Post by Zack Haynes
If
you are not the intended recipient, or the person responsible for
delivering
the message to the intended recipient, please return or delete it
immediately. Although this e-mail and any attachments are believed
to be
Post by Jones Martyn
Post by Zack Haynes
free of any virus or other defect, it is the responsibility of the
recipient
to ensure that it is virus free and no responsibility is accepted by
us
Post by Jones Martyn
Post by Zack Haynes
for
any loss or damage arising in any way from its unauthorized
modification
Post by Jones Martyn
Post by Zack Haynes
or
use.
NOTE: THIS IS A CONFIDENTIAL COMMUNICATION. This transmission is intended
only for the use of the individuals or entity to which it is addressed. If
you are not the intended recipient, or the person responsible for delivering
the message to the intended recipient, please return or delete it
immediately. Although this e-mail and any attachments are believed to be
free of any virus or other defect, it is the responsibility of the recipient
to ensure that it is virus free and no responsibility is accepted by us for
any loss or damage arising in any way from its unauthorized modification or
use.
Peter Crawford
2004-12-01 22:26:33 UTC
Permalink
to work around the platform dependancy issue of such NLS and op.sys
version issues like date and time info, I have been using an altlog
numbering system, for a few(>5) years

In SAS9 it is even easier, but the logic for SAS8 isn't more complex that
this

In your command line, or customised config file, add the option
-config <your preferred path>/upalts.cfg

Then in your autoexec or invoked by -initstmt, call a macro published
previously on SAS-L
%upalts( altlogs\, cfg= <your preferred path>/upalts.cfg );

The macro call echoes to the log, some information about altlog number
that will be used on the next invocation of sas that uses the upalts.cfg
config file.
This is the logic of the main process :
open the named config file for update-in-place
seek -altnum and its counter
update the counter and write back
construct the altlog name with the altlog\ path and new altnum
seek -altlog
write the new path/alt number.log
seek -altprint
write the new math/alt number.lst
report new number
The aparent complexity of these steps, completely becomes taken for
granted.

In operation, it has been convenient to keep the altlogs in their own
subdirectory. v8 an 9 can share the logic if they have independent
upalts.cfg config files. Operating with more than one sas version is
supported also, by set the altnum counter to start at 913000 - but that
was more easily implemented manually <;-)


I recently updated functionality of %upalts to enable the definition, in a
parameter, of the config file that holds the -altlog and -altprint option
settings. But I make mine the default in the macro.

Another feature is, that when it's not present, %upalts will create the
upalts.cfg config file. It seemed simpler to create the required form for
the process, than describe the requirements.

Yet to be implemented, is the setup functionality to create the altlog\
path if it doesn't already exist.

Anyone interested ?

Peter


On Wed, 1 Dec 2004 23:44:55 +1100, Scott
Post by Scott
On my system this returns 01-Dec-04 because of my regional settings. In
addition to PERL, cscript might be another (better?) solution that would
return the date independent of the regional settings.
Post by Jim Groeneveld
=====
@echo off
FOR /f "tokens=2-4 delims=/ " %%a in ('DATE/T') do SET
date=%%c-%%a-%%b
echo DATE is %DATE%
=====
prints
=====
DATE is 2004-11-03
=====
Just leave the dashes out of the FOR statement if you don't want them.
Time is more difficult. The TIME /T command prints only the hour and
minute, without seconds, and uses regional display settings, so you
can't be sure what you'll get back.
If you need the time, you could use the Windows Scripting Host (Visual
Basic or JScript) rather than a batch file. It comes with recent
versions of Windows.
--
Manager, Technical Development
Metrics Department, First Health
West Sacramento, California USA
PM >>>
Look, I love SAS...really! I just think invoking SAS to create a batch
file
to invoke SAS in batch, then scheduling both jobs, is not the best
approach
for this problem. I would argue that, if the native Windows command
interpreter made it easy to capture and format the output of datetime,
that
no here would suggest the below approach; they would say to just
pre-determine the log and lst file names, then invoke SAS
appropriately. I
do agree that installing PERL and, to a lesser extent, learning PERL
(not
much to learn in this scenario), could be an issue.
# Create a string as yymmdd.hhmmss, with zero leading padding
@datetime = localtime;
$dt = join '',
sprintf("%02d",$datetime[5]-100),
sprintf("%02d",$datetime[4]+1),
sprintf("%02d",$datetime[3]),
".",
sprintf("%02d",$datetime[2]),
sprintf("%02d",$datetime[1]),
sprintf("%02d",$datetime[0]); # this is yymmdd.hhmmss
# Where do you want to write the output files?
# Write them to the same path as where this PERL script is located
use Cwd;
$path = cwd();
# Invoke SAS
$cmd = "sas -nologo -icon -sysin \"$path/myprogram.sas\" -log
\"$path/myprogram.$dt.log\" -print \"$path/myprogram.$dt.lst\"";
print $cmd; # for debugging
system $cmd; # comment out during debugging, uncomment to execute
Post by Jones Martyn
Why learn PERL when you've already got SAS? Execute SAS to build the
bat
Post by Jones Martyn
file to do what you want....
Schedule a .bat file containing....
"c:\Program Files\SAS Institute\SAS\V8\sas.exe" -autoexec
D:\Data\SASFiles\V8\batchautoexec.sas -sysin
D:\Data\SASFiles\V8\setbatchdailylog.sas"
Where setbatchdailylog.sas is ....
data _null_;
file 'd:/data/sasfiles/v8/batchdaily.bat';
format date date9. datec $9.;
date=today();
datec=put(date,date9.);
saslit='"c:\Program Files\SAS Institute\SAS\V8\sas.exe"';
autolit=' -autoexec D:\Data\SASFiles\V8\batchautoexec.sas';
sysinlit='-sysin D:\Data\SASFiles\V8\batchdaily.sas';
loglit='-log ' || 'D:\Data\SASFiles\V8\batchdaily'
||substr(datec,6,4)||substr(datec,3,3)
||substr(datec,1,2)||'.log';
put saslit autolit sysinlit loglit;
run;
And subsequently schedule 'd:/data/sasfiles/v8/batchdaily.bat'....
Martyn
-----Original Message-----
Sent: 28 October 2004 12:36
Subject: Re: What do you change to have a unique/numbered LOG/LST
name?
Post by Jones Martyn
If it were me, I'd give up on Windows' brain dead command
interpretter,
Post by Jones Martyn
install ActiveState PERL (free), pre-calculate the timestamp in the
PERL
Post by Jones Martyn
script, and invoke SAS with the -log and -print options. If this
would be
Post by Jones Martyn
an option for you, let me know and I can send you a sample PERL
script
Post by Jones Martyn
that
does exactly what you want.
You can get PERL from http://www.activestate.com/Products/ActivePerl/
Post by Zack Haynes
Dear SAS-L;
What setup changes are needed to allow Win SAS
to create a unique .LOG and .LST file name for
the invoked SAS program. For example, a batch
c:\sas\sas.exe c:\vssdev\saspgm1.sas
SASPGM1.LOG SASPGM1.LST
SASPGM1.041020.132534.LOG SASPGM1.041020.132534.LST
Is this possible? We are using Win SAS 8.2. Thanks.
--
Zac Haynes, Systems & Applications Programmer, 714-404-8840.
ISPF Dialog, REXX, Scripts, SAS, Endevor, DB2, SQL, & Macro.
NOTE: THIS IS A CONFIDENTIAL COMMUNICATION. This transmission is
intended
Post by Jones Martyn
Post by Zack Haynes
only for the use of the individuals or entity to which it is
addressed.
Post by Jones Martyn
Post by Zack Haynes
If
you are not the intended recipient, or the person responsible for
delivering
the message to the intended recipient, please return or delete it
immediately. Although this e-mail and any attachments are believed
to be
Post by Jones Martyn
Post by Zack Haynes
free of any virus or other defect, it is the responsibility of the
recipient
to ensure that it is virus free and no responsibility is accepted by
us
Post by Jones Martyn
Post by Zack Haynes
for
any loss or damage arising in any way from its unauthorized
modification
Post by Jones Martyn
Post by Zack Haynes
or
use.
Loading...