Date: Thu, 2 Mar 2000 16:55:08 -0500
Reply-To: DOUG CONRAD <dconrad@CICINFO.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: DOUG CONRAD <dconrad@CICINFO.COM>
Subject: -thanks -- Can a macro return a value ?
Content-Type: text/plain; charset="iso-8859-1"
I got what I needed.
-----Original Message-----
From: WHITLOI1@westat.com [mailto:WHITLOI1@westat.com]
Sent: Thursday, March 02, 2000 4:43 PM
To: DOUG CONRAD
Subject: Re:Can a macro return a value ?
Doug,
Yes.
%macro Nobs ( data = ) ;
%local d_open getnobs d_close ;
%let d_open =%sysfunc(open(&data));
%let getnobs =%sysfunc(attrn(&d_open,any));
%let d_close =%sysfunc(close(&d_open));
&getnobs
%mend Nobs ;
You could use it in
%if %nobs(data=...) >= 1 %then
%do ;
.......
%end ;
Ian Whitlock <whitloi1@westat.com>
____________________Reply Separator____________________
Subject: Can a macro return a value ?
Author: DOUG CONRAD <dconrad@CICINFO.COM>
Date: 3/2/2000 4:20 PM
can a macro return a value similar to a function?
For example I would like to test the value of the # of obs in a data set but
would like to reference it such as:
%if %getvalue =1 %then %do:
etc; etc;
%end;
Currently I issue a series of %LET statements to do the same:
%let d_open =%sysfunc(open(filex));
%let getnobs =%sysfunc(attrn(&d_open,any));
%let d_close =%sysfunc(close(&d_open));
***** and then get the value returned from a %let statement:
%if &getnobs =1 %then %do;
etc etc;
%end;
I would like to have the '%getvalue' macro return a value (1 0 -1 and such)
that I evaluate after the macro has been evaluated.
(basically, I'm looking for more portability among the various components of
the program I am writing)
Thanks all.