使用多个Where语句

时间:2019-02-12 20:43:49

标签: sas

我正在尝试过滤出REASON_FOR_VISIT变量的字符串中包含特定单词的记录。然后,我想使用其余记录来计算变量total_ed_losarrive_to_dr_sees的中值。

我有以下代码,但恐怕它没有筛选出我想要的字符串。这是我需要使用PROC SQL的实例还是其他选项?

谢谢!

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;

1 个答案:

答案 0 :(得分:1)

如果数据步骤中有多个“ vanilla” where子句,则您将在日志中看到以下内容:

  

注意:WHERE子句已被替换。

为避免此行为,您可以使用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子句已增强。