<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Deleting a SAS Dataset in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Deleting-a-SAS-Dataset/m-p/75408#M21871</link>
    <description>Hello.&lt;BR /&gt;
&lt;BR /&gt;
You can try this macro to delete SAS datasets or any other files in library.&lt;BR /&gt;
You can also use Windows commands.&lt;BR /&gt;
&lt;BR /&gt;
 %macro dirclear(dir=d:\test,ext=xls);&lt;BR /&gt;
 %let ext=%upcase(&amp;amp;ext);&lt;BR /&gt;
 %let dlm=\;&lt;BR /&gt;
 %let filrf=;&lt;BR /&gt;
 %let rc=%sysfunc(filename(filrf,"&amp;amp;dir"));&lt;BR /&gt;
 %let did=%sysfunc(dopen(&amp;amp;filrf));&lt;BR /&gt;
 %let lstname=;&lt;BR /&gt;
 %let memcount=%sysfunc(dnum(&amp;amp;did));&lt;BR /&gt;
 %if &amp;amp;memcount &amp;gt; 0 %then %do;&lt;BR /&gt;
 %do i=1 %to &amp;amp;memcount;&lt;BR /&gt;
 %let lstname=%sysfunc(dread(&amp;amp;did,&amp;amp;i));&lt;BR /&gt;
 %let file=&amp;amp;dir&amp;amp;dlm&amp;amp;lstname;&lt;BR /&gt;
 %let ln=%length(&amp;amp;lstname);&lt;BR /&gt;
  data _null_;&lt;BR /&gt;
  c="&amp;amp;lstname"; c1=reverse(c); ln1=index(c1,'.'); ln=&amp;amp;ln-ln1+2; ln3=ln1-1;&lt;BR /&gt;
  ln4=upcase(substr(c,ln,ln3));&lt;BR /&gt;
  call symput('ln2',trim(left(ln4)));&lt;BR /&gt;
  run;&lt;BR /&gt;
 %if &amp;amp;ln2=&amp;amp;ext or &amp;amp;ext= %then %do;&lt;BR /&gt;
 %let rb=%sysfunc(filename(fname,"&amp;amp;file"));&lt;BR /&gt;
 %let rv=%sysfunc(fdelete(&amp;amp;fname));&lt;BR /&gt;
 %end; %end; %end;&lt;BR /&gt;
 %let rc=%sysfunc(dclose(&amp;amp;did));&lt;BR /&gt;
 %mend dirclear;&lt;BR /&gt;
&lt;BR /&gt;
 libname test v9 'd:\work\test';&lt;BR /&gt;
&lt;BR /&gt;
 %let l=%sysfunc(pathname(test));&lt;BR /&gt;
/* use macro */&lt;BR /&gt;
 %dirclear(dir=&amp;amp;l,ext=sas7bdat);&lt;BR /&gt;
&lt;BR /&gt;
 /* use Windows command */&lt;BR /&gt;
 systask command "del ""&amp;amp;l.\*.sas7bdat"""   wait taskname="del";&lt;BR /&gt;
&lt;BR /&gt;
or use fdelete() function&lt;BR /&gt;
&lt;BR /&gt;
   data _null_;&lt;BR /&gt;
   rc=filename('fname', "&amp;amp;l.\recartis.sas7bdat");&lt;BR /&gt;
   if fexist('fname') then rc=fdelete('fname');&lt;BR /&gt;
   run;&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Regards,&lt;BR /&gt;
Oleg.

Message was edited by: Oleg_1976</description>
    <pubDate>Thu, 15 Apr 2010 11:37:50 GMT</pubDate>
    <dc:creator>Oleg_L</dc:creator>
    <dc:date>2010-04-15T11:37:50Z</dc:date>
    <item>
      <title>Deleting a SAS Dataset</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Deleting-a-SAS-Dataset/m-p/75405#M21868</link>
      <description>How can i delete a sas dataset from a library other than using SAS Datasets procedure.Any macro or functions are there to delete.</description>
      <pubDate>Thu, 15 Apr 2010 08:36:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Deleting-a-SAS-Dataset/m-p/75405#M21868</guid>
      <dc:creator>sas_</dc:creator>
      <dc:date>2010-04-15T08:36:33Z</dc:date>
    </item>
    <item>
      <title>Re: Deleting a SAS Dataset</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Deleting-a-SAS-Dataset/m-p/75406#M21869</link>
      <description>Hi,&lt;BR /&gt;
&lt;BR /&gt;
How about using proc sql delete from or drop table?&lt;BR /&gt;
&lt;BR /&gt;
Milton</description>
      <pubDate>Thu, 15 Apr 2010 08:47:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Deleting-a-SAS-Dataset/m-p/75406#M21869</guid>
      <dc:creator>milts</dc:creator>
      <dc:date>2010-04-15T08:47:55Z</dc:date>
    </item>
    <item>
      <title>Re: Deleting a SAS Dataset</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Deleting-a-SAS-Dataset/m-p/75407#M21870</link>
      <description>You also have PROC DELETE.&lt;BR /&gt;
&lt;BR /&gt;
Scott Barry&lt;BR /&gt;
SBBWorks, Inc.</description>
      <pubDate>Thu, 15 Apr 2010 10:56:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Deleting-a-SAS-Dataset/m-p/75407#M21870</guid>
      <dc:creator>sbb</dc:creator>
      <dc:date>2010-04-15T10:56:15Z</dc:date>
    </item>
    <item>
      <title>Re: Deleting a SAS Dataset</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Deleting-a-SAS-Dataset/m-p/75408#M21871</link>
      <description>Hello.&lt;BR /&gt;
&lt;BR /&gt;
You can try this macro to delete SAS datasets or any other files in library.&lt;BR /&gt;
You can also use Windows commands.&lt;BR /&gt;
&lt;BR /&gt;
 %macro dirclear(dir=d:\test,ext=xls);&lt;BR /&gt;
 %let ext=%upcase(&amp;amp;ext);&lt;BR /&gt;
 %let dlm=\;&lt;BR /&gt;
 %let filrf=;&lt;BR /&gt;
 %let rc=%sysfunc(filename(filrf,"&amp;amp;dir"));&lt;BR /&gt;
 %let did=%sysfunc(dopen(&amp;amp;filrf));&lt;BR /&gt;
 %let lstname=;&lt;BR /&gt;
 %let memcount=%sysfunc(dnum(&amp;amp;did));&lt;BR /&gt;
 %if &amp;amp;memcount &amp;gt; 0 %then %do;&lt;BR /&gt;
 %do i=1 %to &amp;amp;memcount;&lt;BR /&gt;
 %let lstname=%sysfunc(dread(&amp;amp;did,&amp;amp;i));&lt;BR /&gt;
 %let file=&amp;amp;dir&amp;amp;dlm&amp;amp;lstname;&lt;BR /&gt;
 %let ln=%length(&amp;amp;lstname);&lt;BR /&gt;
  data _null_;&lt;BR /&gt;
  c="&amp;amp;lstname"; c1=reverse(c); ln1=index(c1,'.'); ln=&amp;amp;ln-ln1+2; ln3=ln1-1;&lt;BR /&gt;
  ln4=upcase(substr(c,ln,ln3));&lt;BR /&gt;
  call symput('ln2',trim(left(ln4)));&lt;BR /&gt;
  run;&lt;BR /&gt;
 %if &amp;amp;ln2=&amp;amp;ext or &amp;amp;ext= %then %do;&lt;BR /&gt;
 %let rb=%sysfunc(filename(fname,"&amp;amp;file"));&lt;BR /&gt;
 %let rv=%sysfunc(fdelete(&amp;amp;fname));&lt;BR /&gt;
 %end; %end; %end;&lt;BR /&gt;
 %let rc=%sysfunc(dclose(&amp;amp;did));&lt;BR /&gt;
 %mend dirclear;&lt;BR /&gt;
&lt;BR /&gt;
 libname test v9 'd:\work\test';&lt;BR /&gt;
&lt;BR /&gt;
 %let l=%sysfunc(pathname(test));&lt;BR /&gt;
/* use macro */&lt;BR /&gt;
 %dirclear(dir=&amp;amp;l,ext=sas7bdat);&lt;BR /&gt;
&lt;BR /&gt;
 /* use Windows command */&lt;BR /&gt;
 systask command "del ""&amp;amp;l.\*.sas7bdat"""   wait taskname="del";&lt;BR /&gt;
&lt;BR /&gt;
or use fdelete() function&lt;BR /&gt;
&lt;BR /&gt;
   data _null_;&lt;BR /&gt;
   rc=filename('fname', "&amp;amp;l.\recartis.sas7bdat");&lt;BR /&gt;
   if fexist('fname') then rc=fdelete('fname');&lt;BR /&gt;
   run;&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Regards,&lt;BR /&gt;
Oleg.

Message was edited by: Oleg_1976</description>
      <pubDate>Thu, 15 Apr 2010 11:37:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Deleting-a-SAS-Dataset/m-p/75408#M21871</guid>
      <dc:creator>Oleg_L</dc:creator>
      <dc:date>2010-04-15T11:37:50Z</dc:date>
    </item>
  </channel>
</rss>

