Macros for SAS Application Developers
https://github.com/sasjs/core
Loading...
Searching...
No Matches
mp_dropmembers.sas
Go to the documentation of this file.
1/**
2 @file
3 @brief Drops tables / views (if they exist) without warnings in the log
4 @details Useful for dropping tables when you're not sure they exist, or if
5 you are not sure whether they are a dataset or view. Also efficient for
6 dropping multiple tables / views.
7
8 Example usage:
9
10 proc sql;
11 create table data1 as select * from sashelp.class;
12 create view view2 as select * from sashelp.class;
13 %mp_dropmembers(data1 view2, libref=WORK)
14
15
16 <h4> SAS Macros </h4>
17 @li mf_isblank.sas
18
19
20 @param [in] list space separated list of datasets / views, WITHOUT libref
21 @param [in] libref= (WORK) Note - you can only drop from one library at a time
22 @param [in] iftrue= (1=1) Conditionally drop tables, eg if &debug=N
23
24 @version 9.2
25 @author Allan Bowe
26
27**/
28
29%macro mp_dropmembers(
30 list /* space separated list of datasets / views */
31 ,libref=WORK /* can only drop from a single library at a time */
32 ,iftrue=%str(1=1)
33)/*/STORE SOURCE*/;
34
35 %if not(%eval(%unquote(&iftrue))) %then %return;
36
37 %if %mf_isblank(&list) %then %do;
38 %put NOTE: nothing to drop!;
39 %return;
40 %end;
41
42 proc datasets lib=&libref nolist;
43 delete &list;
44 delete &list /mtype=view;
45 run;
46%mend mp_dropmembers;