Reputation: 1577
I execute the following code:
data temp1;
set sashelp.class;
table=1;
run;
data temp2;
set sashelp.class;
table=2;
run;
proc append base=temp1(drop=sex) data=temp2 force;
run;
I thought that sex
will be dropped from temp1. So sex
is missing it will be also dropped from temp2 and result set does not contain column sex
.
However I am irritated by the real result:
Why is sex
for table=1
filled and for table=2
empty?
Upvotes: 1
Views: 360
Reputation: 12691
As @data null mentions, when using proc append the base dataset is not altered. This is the primary reason to use proc append - it does not require a 'pass' of the base dataset, and just appends the data to the end.
In this (rather special) case, the sex
variable is considered dropped and so it is not written/ visible for the subsequent append.
Also (thanks again @data null) there was a clue here from the WARNING in the log. As a matter of best practice, one should always aim to write code that runs without ERRORs or WARNINGs..
Upvotes: 3