我遇到了关于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似乎存在问题,有谁知道问题是什么?非常感谢!