Date: Mon, 30 Apr 2001 21:38:03 +1200
Reply-To: Laurie Fleming <laurief@PARADISE.NET.NZ>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Laurie Fleming <laurief@PARADISE.NET.NZ>
Organization: Dæmons Limited
Subject: Re: Macro Var in open code
> -----Original Message-----
> From: Petruso Steven V [mailto:svpetrus@NEWWESTENERGY.COM]
> Sent: Friday, April 27, 2001 10:18 AM
> To: SAS-L@LISTSERV.UGA.EDU
> Subject: Macro Var in open code
>
>
> Hello all, I run many batch jobs at night for my data warehouse process,
> and
> need a way to create logs of these jobs and incorporate the date of the
> run
> in the log name to keep an archive. I'm not real familiar with macro
> processing, and the following code just creates the log as
> 'test_batch_D&logdate.log', without resolving the macro var. Anyone doing
> something similar or have any good suggestions ?
>
> %let logdate=%sysfunc(today(),mmddyy6.);
> filename logout 'D:\DWroot\Batchjob Logs\test_batch_D&logdate.log';
> proc printto log=logout;
> run;
> <SAS CODE HERE>
> run;
> proc printto;
> run;
>
> TIA
> Steve Petruso
> New West Energy
> Data Warehouse Administrator
> 602-629-7489
> svpetrus@newwestenergy.com
The problem here is that the today function doesn't do any formatting;
it returns an integer as the number of days since 1-Jan-1960. To give it
a value like 050101 (05012001 is of course better...) you need to nest
your sysfuncs:
%let logdate = %sysfunc(putn(%sysfunc(today()), mmddyy6.));
That way today() returns a numeric value (the macro parser doesn't care
that it's numeric, but the putn function does), which is converted into
the value 050101, which is in turn passed to logdate.
Laurie Fleming laurie@sysware.co.nz
Sysware Consulting Group, a SAS Quality Partner
(+64 21) 688-140
|