я интерпретировал ваш вопрос как «Как SAS вернуть дату для среды на прошлой неделе независимо от текущего дня недели?»
, если это желаемый результат, тогданеобходимо два intnx
звонка: один звонок, чтобы вернуться в воскресенье прошлой недели (lastwk=intnx('week', today, -1);
), а затем второй звонок, чтобы перейти в среду прошлой недели (lastwed=intnx('week.4', lastwk , 1);
).
прощеМожно вернуться к началу прошлой недели и просто добавить 3 к результату, но этот код больше похож на хак, чем на преднамеренное смещение.
code
data _null_;
do i = -10 to 10;
today="&SYSDATE9"d + i;
lastwk=intnx('week', today, -1);
lastwed=intnx('week.4', lastwk , 1);
put today weekdate. '-->' lastwed weekdate.-l;
end;
run;
log
Sunday, October 9, 2011-->Wednesday, October 5, 2011
Monday, October 10, 2011-->Wednesday, October 5, 2011
Tuesday, October 11, 2011-->Wednesday, October 5, 2011
Wednesday, October 12, 2011-->Wednesday, October 5, 2011
Thursday, October 13, 2011-->Wednesday, October 5, 2011
Friday, October 14, 2011-->Wednesday, October 5, 2011
Saturday, October 15, 2011-->Wednesday, October 5, 2011
Sunday, October 16, 2011-->Wednesday, October 12, 2011
Monday, October 17, 2011-->Wednesday, October 12, 2011
Tuesday, October 18, 2011-->Wednesday, October 12, 2011
Wednesday, October 19, 2011-->Wednesday, October 12, 2011
Thursday, October 20, 2011-->Wednesday, October 12, 2011
Friday, October 21, 2011-->Wednesday, October 12, 2011
Saturday, October 22, 2011-->Wednesday, October 12, 2011
Sunday, October 23, 2011-->Wednesday, October 19, 2011
Monday, October 24, 2011-->Wednesday, October 19, 2011
Tuesday, October 25, 2011-->Wednesday, October 19, 2011
Wednesday, October 26, 2011-->Wednesday, October 19, 2011
Thursday, October 27, 2011-->Wednesday, October 19, 2011
Friday, October 28, 2011-->Wednesday, October 19, 2011
Saturday, October 29, 2011-->Wednesday, October 19, 2011