| Date: | Wed, 18 Jun 2008 13:22:27 -0700 |
| Reply-To: | "Terjeson, Mark" <Mterjeson@RUSSELL.COM> |
| Sender: | "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU> |
| From: | "Terjeson, Mark" <Mterjeson@RUSSELL.COM> |
| Subject: | Re: datetime do loop macro |
|
| In-Reply-To: | A<7fae10f00806181225q50b16566l555fff6db0b50553@mail.gmail.com> |
| Content-Type: | text/plain; charset="us-ascii" |
Hi Yingtao,
Here is one approach:
%macro get(stmo,enmo);
%put [get] stmo is >&stmo<;
%put [get] enmo is >&enmo<;
%* since datetime is always the first day past stmo, ;
%* then the datetime can always be computed from stmo ;
%* and no need to pass the third argument to this macro ;
%let dttm=%eval(
%sysfunc(intnx(month,%sysfunc(inputn(&stmo,yymmn6.)),1))
*86400);
%put [get] dttm is >&dttm<;
%mend;
%macro perf(theStartMonth,theEndMonth);
%do j = &theStartMonth %to &theEndMonth;
%get(&j.,&theEndMonth);
%let j=%eval(%sysfunc(putn(%sysfunc(intnx(month,
%sysfunc(inputn(&j,yymmn6.)),1)),yymmn6.))-1);
%end;
%mend perf;
%perf(200711,200804);
Hope this is helpful.
Mark Terjeson
Senior Programmer Analyst
Investment Management & Research
Russell Investments
Russell Investments
Global Leaders in Multi-Manager Investing
-----Original Message-----
From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of
yingtao
Sent: Wednesday, June 18, 2008 12:25 PM
To: SAS-L@LISTSERV.UGA.EDU
Subject: datetime do loop macro
Hi All,
Now I have a macro with different parameters like following:
%macro get(start, stop, date);
code...
%mend get;
It is tedious to call the macro by changing the parameters "start" and
"date" as following:
%get(200711,200805,"01Dec2007:00:00:00"dt);
%get(200712,200805,"01Jan2008:00:00:00"dt);
%get(200801,200805,"01Feb2008:00:00:00"dt);
%get(200802,200805,"01Mar2008:00:00:00"dt);
%get(200803,200805,"01Apr2008:00:00:00"dt);
%get(200804,200805,"01May2008:00:00:00"dt);
I am trying to write a do loop macro simplify the call as below, just
stuck with how to do the date part
%macro perf;
%do j=200711 %to 200804;
%get(&j.,200805,"01Dec2007:00:00:00"dt);
%let
j=%eval(%sysfunc(putn(%sysfunc(intnx(month,%sysfunc(inputn(&i,yymmn6.)),
1)),yymmn6.))-1);
%end;
%mend perf;
%perf;
Please advice. Thanks!
Yingtao
|