LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous messageNext messagePrevious in topicNext in topicPrevious by same authorNext by same authorPrevious page (December 2004, week 1)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Wed, 1 Dec 2004 23:44:55 +1100
Reply-To:     Scott <usenet739_yahoo_com_au@CRONKITE.CC.UGA.EDU>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         Scott <usenet739_yahoo_com_au@CRONKITE.CC.UGA.EDU>
Subject:      Re: What do you change to have a unique/numbered LOG/LST name?

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.

"Jack Hamilton" <JackHamilton@FIRSTHEALTH.COM> wrote in message news:s188b6a5.002@SLCM02.firsthealth.com... > 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. > > > > > -- > JackHamilton@FirstHealth.com > Manager, Technical Development > Metrics Department, First Health > West Sacramento, California USA > >>>> Scott <usenet739_yahoo_com_au@CRONKITE.CC.UGA.EDU> 10/31/2004 6:09 > 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 > > > "Jones Martyn" <Martyn.Jones@UK.FUJITSU.COM> wrote in message > news:F8D9355D85FDD41186830090274F19A603E9A996@WWMESSD056... >> 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:usenet739_yahoo_com_au@CRONKITE.CC.UGA.EDU] >> Sent: 28 October 2004 12:36 >> To: SAS-L@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/ > >> >> "Zack Haynes" <Zack.Haynes@BRISTOLWEST.COM> wrote in message >> > news:9EED2986E756964BB16FBE23CB68948D0815D6C1@fldavex01.bristolwest.com... >>> 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.


Back to: Top of message | Previous page | Main SAS-L page