程序1,
data cdw_old_mh&year ;
set Cdw_old&year ( where=( MH=1)) ;
by baseid ;
if (first.baseid ne 1 or last.baseid ne 1) then output ;
run ;
** 112, Unique Elderly community-dwellers with 1+ MH claim;
proc sql;
create table old_g1mh as
select &year as year,count(unique(baseid)) as old_g1MH
from cdw_old_mh&year;
quit;
程序2,
data old_g1_all&year;
set Cdw_old&year ;
by baseid ;
if (first.baseid ne 1 or last.baseid ne 1) then output ;
run ;
proc sql;
create table old_g1_mh as
select &year as year,count(unique(baseid)) as old_g1_MH
from old_g1_all&year
where mh=1;
quit;作者: shiyiming 时间: 2011-11-1 22:09 标题: Re: 为什么这两组程序结果不一样? 举个例子:你的mh=1包含两个baseid。如果先选mh=1,那么经过first。baseid。。。,很能没有输出,因为mh=1在两个不同的baseid都是唯一的记录。所以count应该是0;
如果不先选mh =1,那个这两个记录都有可能被保存,因为每个baseid都有可能包含不止一个mh,直到最有被选出来,count可能是2。
整个的编程逻辑有些绕弯儿。京剧