ESN 是一个 id 列,每个 esn 有多个观察值,因此会出现重复的 esn 值。对于给定的 esn,我想找到最早的服务开始日期(并首先调用它),并且我想找到正确的结束日期(最后调用)关于如何选择“last”的 if/then 语句是正确的,但是运行以下代码时出现以下错误:
340 first = min(of start(*));
---
71
ERROR 71-185: The MIN function call does not have enough arguments.
这是我使用的代码
data three_1; /*first and last date created ?? used to ignore ? in data*/
set three;
format first MMDDYY10. last MMDDYY10.;
by esn;
array start(*) service_start_date;
array stop(*) service_end_date entry_date_est ;
do i=1 to dim(start);
first = min(of start(*));
end;
do i=1 to dim(stop);
if esn_status = 'Cancelled' then last = min(input(service_end_date, MMDDYY10.), input(entry_date_est, MMDDYY10.));
else last = max(input(service_end_date, MMDDYY10.), input(entry_date_est, MMDDYY10.));
end;
run;
“esn” “service_start_date” “service_end_date” “entry_date_est” “esn_status”
1 10/12/2010 01/01/2100 10/12/2012 取消
1 05/02/2009 02/12/2010 10/09/2012 取消
1 04/05/2011 03/04/2100 10/02/2012 取消
结果应该是 first= 05/02/2009 和 last=10/12/2012