0

我遇到了一个关于 SAS 中联合的问题。

1)当我运行下面的代码时:

proc sql;
select count(*) as cnt_obs, count(distinct user) as cnt_user from input1
union all
select count(*) as cnt_obs, count(distinct user) as cnt_user from input2
union all
select count(*) as cnt_obs, count(distinct user) as cnt_user from input3
union all
select count(*) as cnt_obs, count(distinct user) as cnt_user from input4
quit;

我得到了结果:

cnt_obs    cnt_user
10000000   4983437
9771110    4983438
8345177    4983438
8188069    4983438

2)但是根据我在这个proc sql步骤之前的过程,结果的第二列应该是相同的,所以我运行另一个代码来检查我的结果。当我运行下面的代码时:

proc sql;
select count(*) as cnt_obs, count(distinct user) as cnt_user from input1;
select count(*) as cnt_obs, count(distinct user) as cnt_user from input2;
select count(*) as cnt_obs, count(distinct user) as cnt_user from input3;
select count(*) as cnt_obs, count(distinct user) as cnt_user from input4;
quit;

我得到了预期的结果:

cnt_obs    cnt_user
10000000   4983437
9771110    4983437
8345177    4983437
8188069    4983437

3) SAS proc sql 步骤中的 UNION 似乎存在问题,有人知道问题是什么吗?非常感谢!

4

0 回答 0