Date: Tue, 11 Nov 2003 09:39:52 +0000
Reply-To: Robert Walls <robert.walls@EUROPE.PPDI.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Robert Walls <robert.walls@EUROPE.PPDI.COM>
Organization: PPD
Subject: Re: A Macro Problem (ref.: SUGI Paper 100-27)
Content-Type: text/plain; charset=us-ascii
Hi,
I think that what the problem is, is that the macro returns a boolean
variable, 1 for exists and 0 for does not exist, so you need the macro to
resolve in some sort of definition statement. for example it is similar to
a macro I have used before to return the number of obs in a data set:-
%macro nobs(dset) ;
%let dsid=%sysfunc(open(&dset)) ;
%sysfunc(attrn(&dsid,nobs))
%let dsid=%sysfunc(close(&dsid)) ;
%mend nobs ;
%macro yesno(ds);
data &ds.1;
%if %nobs(ptviol) = 0 %then %do;
call symput('dummy', 'YES');
%end;
%else %if %nobs(ptviol) ^= 0 %then %do;
set work.&ds.;
call symput('dummy', 'NO');
%end;
run;
%mend yesno;
%yesno(dataset);
This will generate a macro variable based on the output of the original
macro. Your macro should act in exactly the same was, only 1 for exists
and 0 for does not exist!
I hope this helps,
Rob.
A Druga wrote:
> Hi out there!
>
> I found this little Macro in SUGI Paper 100-27 (Carpenter).
>
> %macro exists(dsn);
> %sysfunc(exist(&dsn));
> %mend exists;
>
> As one can see it is very simple and it's task is easy to understand.
>
> I'm quite new to SAS and now I'm getting following log messages which
> I don't know to interpret:
>
> 5285 %exists(temp1e);
> MLOGIC(EXISTS): Beginning execution.
> MLOGIC(EXISTS): Parameter DSN has value temp1e
> SYMBOLGEN: Macro variable DSN resolves to temp1e
> NOTE: Line generated by the macro function "SYSFUNC".
> 1 1
> -
> 180
> MPRINT(EXISTS): 1;
>
> ERROR 180-322: Statement is not valid or it is used out of proper
> order.
>
> MLOGIC(EXISTS): Ending execution.
>
> The Dataset exists, the macro resolves to the right value and give the
> right output but there is some error which I don't know to eliminate.
> Any hints what I'm doing wrong?
>
> Thank You in advance.
_______________________________________________________
This e-mail transmission and any documents, files or previous email messages attached to it may contain information that is confidential or legally privileged. If you are not the intended recipient or a person responsible for delivering this transmission to the intended recipient, you are hereby notified that you must not read this transmission and that any disclosure, copying, printing, distribution or use of this transmission is strictly prohibited. If you have received this transmission in error, please immediately notify the sender by telephone or return email and delete the original transmission and its attachments without reading or saving in any manner.
|