如何在SAS中仅获取最近4个工作日数据?

时间:2015-07-24 20:53:44

标签: sas

我试图在SAS中仅提取最后4个工作日的数据...我尝试了以下代码,但我没有得到我想要的...

data input;
Input id $ id1 $ id2 $ num date date9.;
Format Date Date9.;
datalines;
x y z 3 19JUL2015
x y z 2 18JUL2015
x y z 3 17JUL2015
x y z 2 16JUL2015
x y z 3 15JUL2015
x y z 2 14JUL2015
x y z 3 13JUL2015
a b c 1 12JUL2015
a b c 1 11JUL2015
a b c 1 10JUL2015
a b c 1 09JUL2015
a b c 1 08JUL2015
a b c 2 07JUL2015
x y z 1 06JUL2015
;
Run;
Data test;
Set input;
Weekday=Weekday(Date);
intck=intck('weekday',Date,today());
*if intck('weekday',Date,today()) >4;
if 1<Weekday(Date)<7 and Date>=today()-4;
Run;

1 个答案:

答案 0 :(得分:0)

我认为您需要撤消&gt;在您的代码中,添加您只想要工作日的资格:

Data test;
  Set input;
  Weekday=Weekday(Date);
  intck=intck('weekday',Date,today());
  if intck('weekday',Date,'20JUL2015'd) le 4 and 1<weekday(Date)<7;
  *if 1<Weekday(Date)<7 and Date>='20JUL2015'd-5;
Run;