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 (October 2009, week 1)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Wed, 7 Oct 2009 11:44:59 -0400
Reply-To:     Ian Whitlock <iw1sas@GMAIL.COM>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         Ian Whitlock <iw1sas@GMAIL.COM>
Subject:      related to macro..............
Comments: cc: gupt <>
Content-Type: text/plain; charset=US-ASCII; format=flowed

Summary: Function style macro #iw-value=1

Macros generate SAS code they do not make functions. However, one can write a macro that will appear to be function call in SAS.

%macro myformula (var) ; &var**2+2*&var+3 /* NO SEMICOLON! */ %mend myformula ;

data test2; set test; y=%myformula(x); run;

In this example you have little more than a technique for data hiding. Now to change the formula, you change the macro instead of the DATA step. Since the macro can be placed anywhere above the DATA step, even in an include file, we have changed the position at which formula changes must be made.

In other words, the DATA step has become stable with respect to simple changes in the formula. This can be very useful in a complex setting.

The other place the technique can be useful is when the formula is complex and it is easier to remember the macro name than the formula.

Ian Whitlock ====================

Date: Wed, 7 Oct 2009 04:51:15 -0700 From: gupt <pvsgupta@GMAIL.COM> Organization: Subject: related to macro..............

Hi, Sas experts,

data test; input x; cards; 5 3 5 2 4 ; run;

i want to create test2 in which i want to include another variable y=x**2+2*x+3; i can write like the following; data test2; set test; y=x**2+2*x+3; run;

but i want to use one user defined function instead of writing the above code. i.e ; data test2; set test; y=%somemacro(); run;

i am not able to prepare this macro.......... if anybody help me it will be very great help to me.

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