LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous (more recent) messageNext (less recent) messagePrevious (more recent) in topicNext (less recent) in topicPrevious (more recent) by same authorNext (less recent) by same authorPrevious page (August 2004, week 1)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Wed, 4 Aug 2004 18:20:26 +0530
Reply-To:     "Patnaik, Tirthankar" <tirthankar.patnaik@CITIGROUP.COM>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         "Patnaik, Tirthankar" <tirthankar.patnaik@CITIGROUP.COM>
Subject:      Re: how to delete datt sets??
Comments: To: Saqi <saqi2000@TOTALISE.CO.UK>
Content-Type: text/plain; charset="iso-8859-1"

Saqi, Well, the problem then is to predefine the macro variable, so that when SAS tries to compare in your %if statement, it has _something_ to compare. Here goes:

options mautosource; %macro z; %let del_list = ; proc sql noprint; select memname into :del_list separated by " " from dictionary.members where compress(libname) like 'WORK' and upcase(substr(memname,1,2)) like 'RA' and verify(substr(memname,3,4),"0123456789") = 0; quit;

%if %cmpres(&del_list.) ne %then %do; /*delete datasets*/ proc datasets lib=work nolist; delete &del_list; run; %end; %mend z;

%z;

This works! :)

best, -Tir

Tirthankar Patnaik India Analytics Center, Asia Pacific Consumer Banking, Citibank, N. A. Chennai 600 002 +91-44-5215 9292 +91-98410 69545

-----Original Message----- From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU]On Behalf Of Saqi Sent: Tuesday, August 03, 2004 4:58 PM To: SAS-L@LISTSERV.UGA.EDU Subject: Re: how to delete datt sets??

tirthankar.patnaik@CITIGROUP.COM (Patnaik, Tirthankar) wrote in message news:<4D99E437F08B6849A39DB6103EA3584901400E3F@EXINMB06.apac.nsroot.net>... > Saqi, > You might wanna try this snippet of code: > > data rasa; x=1; > data ra1234; x=1; > data ra1224; x=1; > data ra1254; x=1; > data ra1284; x=1; > data ra1274; x=1; > data ra12A4; x=1;run; > > proc sql noprint; > select memname > into :del_list separated by " " > from dictionary.members > where compress(libname) like 'WORK' and > upcase(substr(memname,1,2)) like 'RA' and > verify(substr(memname,3,4),"0123456789") = 0; > quit; > > proc datasets lib=work nolist; > delete &del_list.; > quit; > > Of course, you'd get much more flexibility using regular expressions, but they're nowhere as good in SAS as in some other languages I use, like Perl. > > HTH and best, > -Tir > > > > -----Original Message----- > > From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU]On > > Behalf Of Don > > & Susann > > Sent: Friday, July 23, 2004 4:04 PM > > To: SAS-L@LISTSERV.UGA.EDU > > Subject: Re: how to delete datt sets?? > > > > > > Here is a sample that shows what you want. Of course it gets more > > difficult if you have more than more dataset starting with RA that you > > don't want to delete. > > > > data x1 x2 x3 x4 x5 xq1 x6 ; > > run ; > > > > proc datasets lib=work ; > > change xq1=yq1 ; > > delete x: ; > > change yq1=xq1 ; > > quit ; > > > > Don > > > > Saqi wrote: > > > > > Hi their, > > > > > > I am writing a small macro but can't think of anyway round it. I > > > would like that macro to delete data sets that have RANNNN where > > > nnnn=numeric four digit. There is also another data set that is > > > called RASA. I want to delete RANNNN data sets but not RASA. Can > > > anyone help please. > > > > > > Thanks in advance > > > > > > Saqi > > > > > > > > > > -- > > Don Stanley, B.SC, Dip O.R.S, MNZCS > > Author:: Beyond the obvious with SAS Screen Control Language. > > Author:: Solutions for your GUI Applications Development Using SAS/AF > > FRAME Technology > > http://www.syswaregroup.com , http://homepages.rootsweb.com/~ashluke > >

Tir,

Your code works as long as del_list have got something in it. It throws up an error where there is no data set in the library.

I have tried to used the following:

%if &del_list ne %then %do; /*delete datasets*/ proc datasets lib=work nolist; delete &del_list; run; %end;

Running above code I get the following error:

ERROR: A character operand was found in the %EVAL function or %IF condition where a numeric operand is required. The condition was: &del_list ne

Any idea how to ignore if del_list is blank???

Regards

Saqi


Back to: Top of message | Previous page | Main SAS-L page