From: Ya Huang on
Check out this old thread:

http://listserv.uga.edu/cgi-bin/wa?A1=ind0607c&L=sas-l#164

I think the conclusion is not to permanently compile the macro,
instead, %include the source and it will be compiled on the fly.

On Mon, 8 Mar 2010 15:15:11 -0500, SUBSCRIBE SAS-L Dan
<deniseyu001(a)GMAIL.COM> wrote:

>Hi. SASLers:
>
>I have been running SAS using VMS and batch submit for some time. I am
>switching to SAS windows interactively. At present when I run the program,
>I have logs accumulate from last time run. That is not a big deal as long
>as I clear log window every time. However, when come to Sasmacr "catalog"
>in work directory, I am having the real problem. I stored the macros at my
>hard disk and I use the following options:
>options sasautos=('C:\Mymacrolocation');
>After first time the macros compiled, it will not recompile even if I
>modify the macro code at its physical location. What I have to do is to
>physically get into the Sasmacr at work directory and delete them manully.
>
>Is there a program way to delete compiled macro when I run the program? I
>tried the following:
>
> proc datasets library=work kill;
>
>and I got these messages:
>
>NOTE: Deleting WORK.SASMACR (memtype=CATALOG).
>NOTE: File WORK.SASMACR (memtype=CATALOG) cannot be deleted because it is
>in use.
>
>I also interested in deleting the macro vaiables compiled from previous
run.
>
>To be short, I want to mimic the running process as close as possible to
>batch submit. In other words, I want to run program "fresh" every time.
>
>Thanks.
>
>Dan
From: xlr82sas on
On Mar 8, 3:02 pm, ya.hu...(a)AMYLIN.COM (Ya Huang) wrote:
> Check out this old thread:
>
> http://listserv.uga.edu/cgi-bin/wa?A1=ind0607c&L=sas-l#164
>
> I think the conclusion is not to permanently compile the macro,
> instead, %include the source and it will be compiled on the fly.
>
> On Mon, 8 Mar 2010 15:15:11 -0500, SUBSCRIBE SAS-L Dan
>
>
>
>
>
> <deniseyu...(a)GMAIL.COM> wrote:
> >Hi. SASLers:
>
> >I have been running SAS using VMS and batch submit for some time. I am
> >switching to SAS windows interactively. At present when I run the program,
> >I have logs accumulate from last time run. That is not a big deal as long
> >as I clear log window every time. However, when come to Sasmacr "catalog"
> >in work directory, I am having the real problem. I stored the macros at my
> >hard disk and I use the following options:
> >options sasautos=('C:\Mymacrolocation');
> >After first time the macros compiled, it will not recompile even if I
> >modify the macro code at its physical location. What I have to do is to
> >physically get into the Sasmacr at work directory and delete them manully.
>
> >Is there a program way to delete compiled macro when I run the program? I
> >tried the following:
>
> > proc datasets library=work kill;
>
> >and I got these messages:
>
> >NOTE: Deleting WORK.SASMACR (memtype=CATALOG).
> >NOTE: File WORK.SASMACR (memtype=CATALOG) cannot be deleted because it is
> >in use.
>
> >I also interested in deleting the macro vaiables compiled from previous
> run.
>
> >To be short, I want to mimic the running process as close as possible to
> >batch submit. In other words, I want to run program "fresh" every time.
>
> >Thanks.
>
> >Dan- Hide quoted text -
>
> - Show quoted text -

Hi,

This is an important issue for interactive users, I have a macro I
will add to my tips that basically resets everthing back to were it
was when you invoked SAS. You do have to put an optsave in your
autoexec though. You do not need to go to my site for the answer to
your question, I pasted the code below.

Here is my current tip for deleting all macros except the one that is
resetting the environment

for a cleaner version and eventual utl_resetenv macro see

/* T002150 CLEAR ALL COMPILED MACROS AND ALL GLOBAL MACRO VARIABLES */
note local macro variables disapear after the macro compiles.

in

http://homepage.mac.com/magdelina/.Public/utl.html
utl_tipweb.sas


/* T002150 CLEAR ALL COMPILED MACROS AND ALL GLOBAL MACRO VARIABLES */
*clear compiled macros;
proc catalog catalog=work.sasmacr; %* CLEAR compiled macros
*;
contents out=_tempcompmacs;
quit;
proc sql noprint;
select distinct(name) into :work_compiled_macros separated by ' '
from _tempcompmacs
where upcase(name) ne 'UTL_REINVOKE';
quit;
proc catalog catalog=work.sasmacr;
delete &work_compiled_macros / ET = macro;
quit;

*clear all global macro vars;
data _delgvars; %* CLEAR ALL GLOBAL VARS
*;
set sashelp.vmacro
(where=( scope='GLOBAL' &
name not in ('AFTLAST' 'SYSROOT' 'SYSLEVEL') ));
run;
proc sort data=_delgvars nodupkey;
by name;
run;
data _null_;
set _delgvars;
call execute('%symdel ' !! trim(left(name)) !! ';');
run;
From: NordlDJ on
> -----Original Message-----
> From: SAS(r) Discussion [mailto:SAS-L(a)LISTSERV.UGA.EDU] On Behalf Of
> SUBSCRIBE SAS-L Dan
> Sent: Monday, March 08, 2010 12:15 PM
> To: SAS-L(a)LISTSERV.UGA.EDU
> Subject: Running SAS on PC, need to delete old compiled macro
>
> Hi. SASLers:
>
> I have been running SAS using VMS and batch submit for some time. I am
> switching to SAS windows interactively. At present when I run the program,
> I have logs accumulate from last time run. That is not a big deal as long
> as I clear log window every time. However, when come to Sasmacr "catalog"
> in work directory, I am having the real problem. I stored the macros at my
> hard disk and I use the following options:
> options sasautos=('C:\Mymacrolocation');
> After first time the macros compiled, it will not recompile even if I
> modify the macro code at its physical location. What I have to do is to
> physically get into the Sasmacr at work directory and delete them manully.
>
> Is there a program way to delete compiled macro when I run the program? I
> tried the following:
>
> proc datasets library=work kill;
>
> and I got these messages:
>
> NOTE: Deleting WORK.SASMACR (memtype=CATALOG).
> NOTE: File WORK.SASMACR (memtype=CATALOG) cannot be deleted because
> it is
> in use.
>
> I also interested in deleting the macro vaiables compiled from previous run.
>
> To be short, I want to mimic the running process as close as possible to
> batch submit. In other words, I want to run program "fresh" every time.
>

Is there some reason why you just don't continue to run in batch mode on windows? Just wondering.

Dan

Daniel J. Nordlund
Washington State Department of Social and Health Services
Planning, Performance, and Accountability
Research and Data Analysis Division
Olympia, WA 98504-5204
From: Jim Groeneveld on
Hi Dan,

Once SAS finds a/your source code macro for the first time it compiles it
(to its work macro catalog) and never again searches for it during the run
(the SAS session); that is quite logical. So it won't know whether the macro
source code might have changed in the meantime. If you know it changed you
should explicitly tell SAS so by feeding the new code to SAS, forcing it to
compile that again and use from then on. You do that for example by
%INCluding the macro's source code.

Macro code may explicitly be redefined as often as desired:
%MACRO Testing;
%PUT This is the first version of the macro Testing;
%MEND;
%Testing

%MACRO Testing;
%PUT This is the second version of the macro Testing;
%MEND;
%Testing

%MACRO Testing;
%PUT This is the third version of the macro Testing;
%MEND;
%Testing

You don't need to delete a macro (I think it is possible, but I never needed
it); you just can redefine/overwrite a macro.

Unless you explicitly have a need for a chameleon-like macro I would advise
against macros with same names but different, varying code. Instead it may
be possible to call variant code using a specific paramater value when
calling an unchangeable macro.

However, if you can't avoid a changing macro you may use the option MRECALL,
but that causes all macros used to be searched and compiled every time when
called.

Regards - Jim.
--
Jim Groeneveld, Netherlands
Statistician, SAS consultant
http://jim.groeneveld.eu.tf



On Mon, 8 Mar 2010 15:15:11 -0500, SUBSCRIBE SAS-L Dan
<deniseyu001(a)GMAIL.COM> wrote:

>Hi. SASLers:
>
>I have been running SAS using VMS and batch submit for some time. I am
>switching to SAS windows interactively. At present when I run the program,
>I have logs accumulate from last time run. That is not a big deal as long
>as I clear log window every time. However, when come to Sasmacr "catalog"
>in work directory, I am having the real problem. I stored the macros at my
>hard disk and I use the following options:
>options sasautos=('C:\Mymacrolocation');
>After first time the macros compiled, it will not recompile even if I
>modify the macro code at its physical location. What I have to do is to
>physically get into the Sasmacr at work directory and delete them manully.
>
>Is there a program way to delete compiled macro when I run the program? I
>tried the following:
>
> proc datasets library=work kill;
>
>and I got these messages:
>
>NOTE: Deleting WORK.SASMACR (memtype=CATALOG).
>NOTE: File WORK.SASMACR (memtype=CATALOG) cannot be deleted because it is
>in use.
>
>I also interested in deleting the macro vaiables compiled from previous run.
>
>To be short, I want to mimic the running process as close as possible to
>batch submit. In other words, I want to run program "fresh" every time.
>
>Thanks.
>
>Dan
From: SUBSCRIBE SAS-L Dan on
Hi. Daniel:

I switched from batch mode to SAS window interactive because I am writing
the whole code (header program and macro programs) interactively; also I
want to run the code on the interactive SAS window so I may be able to
check the temporary data sets in the work library. Thanks.

Dan