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
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
|