Dec 1, 2012

SAS Macro to delete a SAS dataset

Here’s a simple SAS Macro to delete a SAS dataset…It takes the name of the SAS dataset as the parameter…
%macro deletedsn(dsname);
 
%if %index(&dsname,.) eq 0  %then %do; %let lib=work; %let dsn=&dsname; %end;
%else %if %index(&dsname,.) gt 0  %then %do; %let lib=%scan(&dsname,1,.); %let dsn=%scan(&dsname,2,.); %end;
 
proc datasets lib=&lib nolist;
 delete &dsn;
quit;
%mend deletedsn;
 
%deletedsn(new);
%deletedsn(somelib.new);

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.