Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

intnx

Status
Not open for further replies.

shenniko

Programmer
Apr 15, 2005
52
US
Hi all,

Need some help with the below statement:-

Code:
	if  run_day = 1 then sunday=&last_rundate-7;
	else sunday =  intnx('week.2',&last_rundate,-2,'end');

Last_rundate is today()-1;
run_day = weekday(&last_rundate);

I've been trying to figure out what the above does for the past day now, i know it looks to see if run_day is sunday, if so then make "sunday" = last sundays date... its just the part after i dont understand.

thanks

Shenn
 
Shenniko,
The code looks like it tries to calculate the last Sunday in your logic. (I am not sure what your program's purpose at this point, but don't let that stand in your way :) )

Like you suggested your first line checks that run_day is a sunday then sets the appropiate value to a variable named 'sunday'.
If run_day's evaluation doesn't return a 'true' (meaning it isn't sunday today (or when the script is run) ) then it tries to get the last date that your code cares about (I am not sure if that is when it ran or calculated a value..) by using the intnx function. This function can tell you the date between intervals. Say I want to know the date of 4 weeks ago from today feb 12, 2007 in 6 day intervals. (in other words 24 days ago.) I can do the following.
ex.
Code:
data _null_;
  four_wks_ago_dt = intnx('week.2','12feb2007'd,-4);
  put four_wks_wo_sun_dt=;
  format four_wks_wo_sun_dt mmddyy10.;
run;

the Week.2 label = 6 days. Your code is trying to set the sunday variable to a specific date in time by using this function.

I hope that this has helped you.
Klaz
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top