[英]How can I fix my where clause in SAS
I have a table is SAS say t
looking like this 我有一个表是SAS说t
这样看
A B C D
--------------------------------------------------------------
VOLUME 172631922966528 IMPLIED 2012-10-04
VOLUME 173731441803264 IMPLIED 2012-10-04
PRIX_VOLUME 189124634214400 IMPLIED 2012-10-04
PRIX_VOLUME 123153895784448 IMPLIED 2012-10-04
VOLUME 266090408574976 IMPLIED 2012-10-04
VOLUME 119855364243456 IMPLIED 2012-10-04
The column D is a Date
(format yymmdd10
) colume and I have a macrovarible date0
that is worth 2012-10-04
I am trying to do a trivial data-step D列是Date
(格式yymmdd10
)列,并且我有一个值得2012-10-04
的宏date0
,我正在尝试执行一个简单的数据步骤
data test;
set t (where=(A eq "VOLUME" and D eq &date0.));
run;
but this is not working 但这不起作用
Can you help fix it ? 你能帮忙解决吗?
That is because when the macro variable is processed, you get: 这是因为在处理宏变量时,您将获得:
data test;
set t (where=(A eq "VOLUME" and D eq 2012-10-04));
run;
Which SAS will resolve as: data test; 哪种SAS可以解决:数据测试; set t (where=(A eq "VOLUME" and D eq 1998)); 设置t(其中=(Aeq“ VOLUME”和Deq 1998)); run; 跑; Because it sees math instead of a date. 因为它看到的是数学而不是日期。 You need to make clear to SAS that: 您需要向SAS明确说明:
1. it is not algebra. 1.不是代数。
2. it should read it as a date. 2.应该将其作为日期阅读。
To make it read it as a string, add quotes. 要使其以字符串形式读取,请添加引号。 To make clear that the string represents a date, append ad after the quotes: 为了使字符串表示日期,请在引号后附加广告:
data test;
set t (where=(A eq "VOLUME" and D eq "&date0."d));
run;
That should do the trick. 这应该够了吧。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.