|
ArjenR wrote:
> Hello SAS-L'ers,
>
> Why would it be that the macro below (not my own code) doesn't work as
> an autocall macro?
> The problem seems to be that the proc format doesn't create the 2
> formats needed for the macro.
>
> It was my assumption that the macro call causes SAS to look for a file
> with the same name, which is then 'included' in the program code with
> all it contains, also possible extra code like the proc format in this
> case. Is this assumption wrong or is there something else amiss?
>
> Thanks,
> Arjen Raateland
> Finnish Environment Institute
> Helsinki
>
> /* Informat and format -- MUST be in existence when macro STDTIME is
> called. */
> proc format ;
> invalue STDSHFT /* Time difference (hours) between local time and
> UTC time. */
> "01" = -1 /* ~ MET zone */
> "02" = -2 /* ~ EET zone */
> ;
> value $DAYLITE /* Indicates whether daylight saving time is to be
> used. */
> "01" = "YES" /* ~ MET zone */
> "02" = "YES" /* ~ EET zone */
> ;
> run;
>
> %macro STDTIME(LOC,SASDTTM);
> %let YR = YEAR(DATEPART(&SASDTTM));
> %let LASTSUNMAR = DHMS(INTNX("WEEK",MDY( 4,1,&YR)-1,0),3,0,0);
> %let LASTSUNOCT = DHMS(INTNX("WEEK",MDY(11,1,&YR)-1,0),4,0,0);
> (
> &SASDTTM +
> 3600 * (
> (input (&LOC,STDSHFT.)) - (((&LASTSUNMAR<=&SASDTTM<=&LASTSUNOCT)
> and (PUT(&LOC,$DAYLITE.)="YES" )))
> )
> )
> %mend STDTIME;
The use of %STDTIME may preclude or otherwise confound the desire of the
autocall system to run the code.
E.g. If the usage was thus:
data _null_;
c = %STDTIME(foo,bar);
run;
The proc format could not run (the first time STDTIME is invoked in the
session) because the SAS executor is already processing the data _null_. At
best it might short cut the data step ?
SAS uses 'loaded' autocall macros.
For instance
%ANNOMAC causes all the annotation macros to be loaded.
You might want your STDTIME macro in an autocall source named arjenmac.sas,
and use as follows
%ARJENMAC
data _null_;
c = %STDTIME(foo,bar);
run;
--
Richard A. DeVenezia
http://www.devenezia.com/
|