Wednesday, December 15, 2010

Find out start and end date of a week

-
data _null_;
*The intnx function can be used to find out the end date of a week (when the user is in the middle of the week);
start=intnx('week',today(),1)-1;
*Then user can then apply the below code to fetch another 12 weeks of data from this weekend date;
end=(start+7*12);
call symput('start_dt',put(start,date9.));
call symput('end_dt ',put(end,date9.));
run;
%put &start_dt &end_dt;

*In a same way the user can find out a start date of a week;
example=intnx('week',today(),0);
-
More: http://www2.sas.com/proceedings/sugi30/255-30.pdf
-

No comments:

Post a Comment