|
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
|