我每周四都会有一份SAS工作,但有时需要在周三或周二晚上运行。 该工作每隔4周收集一些数据直到最近的星期日。 例如,今天我们有2015年的19月,我需要的数据直到2015年3月15日。
data get_some_data; set all_the_data; where date >= '16Feb2015' and date <= '15Mar2015'; run;下周我也必须手动更改日期参数
data get_some_data; set all_the_data; where date >= '23Feb2015' and date <= '22Mar2015'; run;无论如何,我可以自动化呢?
I have a SAS job that runs every Thursday, but sometime it need to run on Wednesday, and maybe Tuesday evening. The job collects some data in 4 week intervals up until the closest Sunday. For example, today we have 19Mar2015, and I need data until 15Mar2015.
data get_some_data; set all_the_data; where date >= '16Feb2015' and date <= '15Mar2015'; run;Next week I have to manually change the date parameters too
data get_some_data; set all_the_data; where date >= '23Feb2015' and date <= '22Mar2015'; run;Anyway I can automate this?
最满意答案
我会扩展@ user667489的建议,因为它可能需要一段时间才能解决。 关键是要使用week时间间隔,默认情况下星期天开始(您可以用换档指数改变它,请阅读此处了解更多详情)
所以你的查询只需要是:
where intnx('week',today(),-4)<date<=intnx('week',today(),0);I'll expand on the suggestion from @user667489 as it could take you a while to work it out. The key is to use the week time interval, which by default starts on a Sunday (you can change this with a shift index, read this for further details)
So your query just needs to be :
where intnx('week',today(),-4)<date<=intnx('week',today(),0);更多推荐
发布评论