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>
Subject: Re: A Macro Problem (ref.: SUGI Paper 100-27)
Content-Type: text/plain; charset=us-ascii
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)) ;
%let dsid=%sysfunc(close(&dsid)) ;
%mend nobs ;
%if %nobs(ptviol) = 0 %then %do;
call symput('dummy', 'YES');
%else %if %nobs(ptviol) ^= 0 %then %do;
call symput('dummy', 'NO');
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,
A Druga wrote:
> Hi out there!
> I found this little Macro in SUGI Paper 100-27 (Carpenter).
> %macro exists(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
> MPRINT(EXISTS): 1;
> ERROR 180-322: Statement is not valid or it is used out of proper
> 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.