Reputation: 617
Say I have two data sets.
Work.one
,Work.two
.
Work.one
X Y
3 4
2 4
Work.two
Z
10
Then I submit the following program.
data work.wh;
if _n_ = 1 then set Work.two;
set Work.one;
run;
The output data set is
work.wh
Z X Y
10 3 4
10 2 4
But actually I want something like
work.wh
Z X Y
10 3 4
. 2 4
Could anyone explain why I get those results and how can I output the data set as expected?
Upvotes: 0
Views: 54
Reputation: 63424
Variables that are defined in a set/merge/update statement are retained. If you want it to be set to missing, you need to do that by hand.
data work.wh;
if _n_ = 1 then set Work.two;
else call missing(z);
set Work.one;
run;
Upvotes: 3