|
Hi Matt,
The first thing to remember is that ALL
macro stuff is string text as string
substitution. Therefor chop out the
year characters out of the string and
since the macro stuff is string the %eval()
function will convert the string internally
and perform the arithmetic and then convert
the result back to string being returned.
%macro test(MONTH);
%let m=%eval(%substr(&MONTH,1,4)+2)%substr(&MONTH,5,2);
%put &m;
%mend test;
%test(200405);
Hope this is helpful.
Mark Terjeson
Senior Programmer Analyst, IM&R
Russell Investment Group
Russell
Global Leaders in Multi-Manager Investing
-----Original Message-----
From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of
Mark
Sent: Thursday, June 16, 2005 2:15 PM
To: SAS-L@LISTSERV.UGA.EDU
Subject: How to covert macro variable to number and assign back to macro
variable
I need to pass a month variable into my macro.
Then I want to convert it to number, and increase it by 200.
Say if the value is 200405, then after pass in into macro
I want to get 200605 and assign it to a new macro variable.
%macro test(MONTH)
m=&MONTH;
%mend test;
For instance, in above code, &MONTH contain value of 200405.
I want to get 200605(200405+200) and assign it to a new macro
variable(&MONTH_NEW).
Thanks,
Matt
|