> From: William [mailto:tien.w@MELLON.COM]
> I run a job bi-weekly and save a sas permanent dataset to
> sas library. I need to erase datasets of previous month so
> that current month datasets have enough space to store.
> Here is the macro:
> %MACRO DELLAST(INDATE) ;
> DATA _NULL_;
> D28AGO = &INDATE - 28;
> MMDD = SUBSTR(PUT(D28AGO,YYMMDD6.),3,4);
> CALL SYMPUT('MMDD',MMDD);
> PROC DATASETS LIB = SASLIB; * SASLIB is DDname called from JCL *;
> DELETE D&MMDD;
> %MEND ;
> Since the indate is user run date, there is no guarantee that
> dataset of (indate - 28) exist. Furthermore, I want to
> implement this macro to all programs with different rundates.
you are passing a parameter MMDD
-- which is a suffix of a data set name --
to your delete statement in proc DataSets.
in the worst case
this results in generating a delete statement
that has invalid data set name.
I suggest you pass the complete delete statement:
delete <Data Set Name>;
to proc DataSets,
in the worst case there is no delete statement
and proc DataSets does nothing,
most gracefully, I might add.
set code below .sig
which you will note requires no macro
only macro variables as parameters
Ron Fehd the SQL into:macroVar maven CDC Atlanta GA USA RJF2@cdc.gov
By using your intelligence
you can sometimes make your problems twice as complicated.
-- Ashleigh Brilliant
%Let Prefix =
%Let Libref = Work;%*Testing;
%Let SQLprint = Print;%*Testing;
%*Let SQLprint =noPrint;%*production;
PROC Sql &SQLprint.;
select 'delete ' !! MemName !! ';'
separated by ' '
where LibName eq "&Libref."
PROC Datasets library = &Libref.
memtype = data
%symdel LibRef List2Del SQLprint Prefix;