使用多个 Where 语句 [英] Using Multiple Where Statements
问题描述
我正在尝试过滤掉包含 REASON_FOR_VISIT
变量的字符串中特定单词的记录.然后我想使用剩余的记录来计算变量 total_ed_los
和 arrive_to_dr_sees
的中值.
I'm attempting to filter out records that contain specific words within a string for the REASON_FOR_VISIT
variable. I then want to use the remaining records to compute the median values for the variable total_ed_los
and arrive_to_dr_sees
.
我有以下代码,但恐怕它没有过滤掉我想要的字符串.这是我需要使用 PROC SQL
的实例还是有其他选择?
I have the following code but I'm afraid that it's not filtering out the strings I would like it to. Is this an instance I need to use PROC SQL
or are there other options?
谢谢!
data FT_Post;
set WORK.FT_May;
Where checkin_time between '12:00't and '20:00't;
Where REASON_FOR_VISIT Not Like '%psyc%';
Where REASON_FOR_VISIT Not Like '%psy eval%';
Where REASON_FOR_VISIT Not Like '%psych%';
Where REASON_FOR_VISIT Not Like '%suicid%';
Where REASON_FOR_VISIT Not Like '%homicid%';
run;
proc means data=FT_Post median;
class checkin_date;
var total_ed_los arrive_to_dr_sees;
run;
推荐答案
如果您在一个数据步骤中有多个vanilla"where 子句,您将在日志中看到以下内容:
If you have multiple 'vanilla' where clauses in a datastep you will see the following in the log:
注意:WHERE 子句已被替换.
NOTE: WHERE clause has been replaced.
为了避免这种行为,你可以使用 where also
:
To avoid this behaviour, you can use where also
:
data FT_Post;
set WORK.FT_May;
Where checkin_time between '12:00't and '20:00't;
Where also REASON_FOR_VISIT Not Like '%psyc%';
Where also REASON_FOR_VISIT Not Like '%psy eval%';
Where also REASON_FOR_VISIT Not Like '%psych%';
Where also REASON_FOR_VISIT Not Like '%suicid%';
Where also REASON_FOR_VISIT Not Like '%homicid%';
run;
您现在将看到:
注意:WHERE 子句已增加.
NOTE: WHERE clause has been augmented.
这篇关于使用多个 Where 语句的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!