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 (March 2000, week 1)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
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 ?
Comments: To: SAS List <sas-l@uga.cc.uga.edu>
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.


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