@jaiganesh wrote:
Retain Keyword (...) what would be it's alternative for Macro to do incremental addition
Hello @jaiganesh,
The primary purpose of the RETAIN statement in the DATA step is to prevent certain variables from being reset to missing at the beginning of a new iteration of the DATA step (implied loop).
In a SAS macro:
- there is neither an implied loop nor a mechanism that automatically (iteratively) clears macro variables.
- Incremental additions (if any) would typically occur in a %DO loop and don't require anything similar to a RETAIN statement (which wouldn't be needed even in an analogous DATA step DO loop anyway).
Example:
%macro test;
%let s=0;
%do i=20 %to 40 %by 10;
%let s=%eval(&s+&i);
%end;
%put &=s; /* result: 90 */
%mend test;
%test