LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous messageNext messagePrevious in topicNext in topicPrevious by same authorNext by same authorPrevious page (June 2004, week 2)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:   Wed, 9 Jun 2004 11:57:10 -0400
Reply-To:   "Richard A. DeVenezia" <radevenz@IX.NETCOM.COM>
Sender:   "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:   "Richard A. DeVenezia" <radevenz@IX.NETCOM.COM>
Subject:   Re: Retreiving record Counts through Macro ATTRN

Easwara Moorthy wrote: > Hi all, . > %let rc=%sysfunc(where(&dsid,'a=1')); . > I'm gettin error that 'ERROR: The WHERE function referenced in the > %SYSFUNC or %QSYSFUNC macro function is not found.' > > is there any other way to get a solution?? > The WHERE() function is an SCL-only function. It is not available to Data Step (and thus not available to macro). Take the time to write sensible macros with local variables, its worth the effort. %get doesn't cut it as sensible.

You can place your where criteria as a where= data set option in the dataset parameter of the OPEN() function.

data one; a=1;output; a=1;output; a=1;output; a=2;output; a=1;output; a=2;output; run;

%macro NLOBSF (data=); %local dsid nlobsf rc; %let dsid = %sysfunc(open(&data)); %if &dsid %then %do; %let nobs =%sysfunc(attrn(&dsid,NLOBSF)); %let rc = %sysfunc(close(&dsid)); &nobs %end; %else -1 %mend;

%put %NLOBSF(data=one(where=(a=1))); %put %NLOBSF(data=one(where=(a^=1))); %put %NLOBSF(data=one); %put %NLOBSF(data=foobar);

More generalized might be

%macro attrn (data=, attr=); .... %let attrn_return = %sysfunc(attrn(&dsid,&attr)); ... &attrn_return ... %mend

%put %ATTRN (data=..., attr=NLOBSF);

An even more general form for encapsulating attrn/c is plausible.

Take a look at Rolands macros, he has done tons of this already. (http://www.datasavantconsulting.com/roland/ sasauto extensions) I think another utility minded macro author goes by a moniker something like xlr82sas. And all the other guys-n-gals too numerous to mention...

-- Richard A. DeVenezia http://www.devenezia.com/downloads/sas/macros


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