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ステップの前の私のプロセスによれば、結果の2番目の列は同じでなければならないので、別のコードを実行して結果を確認します。以下のコードを実行すると:
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 に問題があるようですが、誰が問題を知っていますか? どうもありがとう!