Date: Fri, 6 Oct 2006 22:29:43 +0000
Reply-To: toby dunn <tobydunn@HOTMAIL.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: toby dunn <tobydunn@HOTMAIL.COM>
Subject: Re: Compute macro variables
In-Reply-To: <1160171628.021691.73030@h48g2000cwc.googlegroups.com>
Content-Type: text/plain; format=flowed
I just wrote a paper for NESUG and SESUG over this very topic:
Go here:
http://www.albany.edu/faculty/msz03/nesug06/cc/cc21.pdf
Toby Dunn
When everything is coming at you all at once, your in the wrong lane.
A truly happy person is someone who can smile and enjoy the scenery on a
detour.
From: mahesh.tamboli@GMAIL.COM
Reply-To: mahesh.tamboli@GMAIL.COM
To: SAS-L@LISTSERV.UGA.EDU
Subject: Compute macro variables
Date: Fri, 6 Oct 2006 14:53:48 -0700
Hi there,
The code below does the following. Based on the current month computes
the year and month for the last 12 months and pulls the relevant data .
The code works, but the issue is the way it is coded. Since 2 new macro
variables need to be computed based on the current month date, a data
_NULL_ step is used. Here, I am trying to explore any other
alternatives that will help me to avoid using a data step (and
work.cust_data dataset).
Appreciate any suggestions..
Thanks,
/* Code Begins here */
%let cm_dt = '1sep06'd;
%macro auto;
%DO N = 1 %TO 12;
data _NULL_;
set work.cust_data; /* Uses a existing temp dataset */
format year $CHAR4.;
format month $CHAR2.;
year = substr(put(intnx('month', &cm_dt, &N - 8), yymmddn8.),
1,4);
month = left(substr(put(intnx('month', &cm_dt, &N - 8), yymmddn8.),
5,2);
call symput('year', year);
call symput('month',month);
run;
libname old_ds "/marketing/data/&year/&month";
data result_&N;
merge old_ds.acct_info (in = key1)
work.temp11 (in = key2);
if (key1 and key2)
run;
%END;
%mend;
%auto; /* Macro Call */