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 (November 2009, week 3)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Mon, 16 Nov 2009 18:07:00 -0800
Reply-To:     John Uebersax <jsuebersax@GMAIL.COM>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         John Uebersax <jsuebersax@GMAIL.COM>
Organization: http://groups.google.com
Subject:      Calling a macro like a function
Comments: To: sas-l@uga.edu
Content-Type: text/plain; charset=ISO-8859-1

Hello Group,

In terms of the example below, how can one use a macro to work like a function?

The goal is to call the macro to add x and y, and to save the sum, z, in the dataset for each record. How does one ask the macro to 'return' the computed value to the calling statement. It seems simple, but I've never used a macro this way before.

data one; x=1; y=1; output; x=2; y=3; output; run;

data two; set one; %add_numbers( x, y, z); run;

%macro add_numbers (x, y, z) z = &x + &y; %mend

Thanks in advance.

John Uebersax http://www.john-uebersax.com


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