+--------------+--------------+
| switch_time1 | switch_time2 |
+--------------+--------------+
| 8:00:15 | 8:32:15 |
| 9:12:13 | 9:18:13 |
| 18:20:36 | 18:46:36 |
+--------------+--------------+
如何在SAS proc sql中使用正确的时间计算格式?
PROC SQL;
CREATE TABLE MC_ET AS
SELECT
sum(case when switch_time2-switch_time1>5 minutes and switch_time2-switch_time1<10mintues then 1 else 0 end) as Count_of_8,
sum(case when switch_time2-switch_time1>10 minutes and switch_time2-switch_time1<15mintues then 1 else 0 end as count_of_9, ...
FROM have
;
QUIT;
答案 0 :(得分:1)
您非常接近。请注意,时间以秒为单位存储,因此您的条件乘以60(5分钟* 60秒/分钟)= 300秒
PROC SQL;
CREATE TABLE MC_ET AS
SELECT
sum(case when switch_time2-switch_time1> (5*60) and switch_time2-switch_time1< (10*60) then 1 else 0 end) as Count_of_8,
sum(case when switch_time2-switch_time1>(10*60) and switch_time2-switch_time1<(15*60) then 1 else 0 end as count_of_9, ...
FROM have
;
QUIT;