From: William Shakespeare on
I have a rollup in a data step that looks like this:

%let enddate='31NOV09'd;

data want;
set have;
if substr(put(&enddate,date9.),3,3)='NOV' then do;
if substr(put(trans_date,date9.),3,3)='DEC' or
if substr(put(trans_date,date9.),3,3)='JAN' or
if substr(put(trans_date,date9.),3,3)='FEB'
then do;
startday='01JAN;
enday='28FEB'
end;
end;

if not missing(startday) & not missing(endday) then do;
if datepart(trans_date)>=input(cats(startday,2007),date9.) &
if datepart(trans_date)<=input(cats(endday,2007),date9.)
then do;
sales_2007+sales;
end;
end;

if not missing(startday) & not missing(endday) then do;
if datepart(trans_date)>=input(cats(startday,2008),date9.) &
if datepart(trans_date)<=input(cats(endday,2008),date9.)
then do;
sales_2008+sales;
end;
end;

run;

This works fine except that it excludes 29FEB08. Is there an easy way of
incrementing endday by one for leap years without rewriting all this code?
I want to expand this code to cover other 3 month periods which is easy
enough but the leap year thing has got me stumped. Be nice if I could get
away with: if datepart(trans_date)<=input(cats(endday+1,2008),date9.) Maybe
best if I explicitly specified if datepart(trans_date)<='29FEB09'd for 2008.
Suggestions?
 | 
Pages: 1
Prev: result
Next: Capture MAC address into SAS