|
How about this interpretation:
When using "set have have2": once SAS detects the end of have, it erases PDV
and continues to have2.
When using "set have have2 nobs=_nobs point=_point;": There is no way for
SAS to detect the end of have, so the value 3 got retained when SAS is
processing the case when _nobs=4.
Max
(Maaxx)
-----Original Message-----
From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of Data
_null_;
Sent: July-15-11 6:17 PM
To: SAS-L@LISTSERV.UGA.EDU
Subject: Re: [SAS-L] very interesting! set one two ..., what's make the
difference?
On Fri, Jul 15, 2011 at 4:37 PM, Jim Groeneveld <jim.1stat@yahoo.com> wrote:
> Need2 is a concatenation of both datasets Have and Have2, generated from
the
> implicit data step iteration that sets every variable, NOT occurring in a
> dataset read, to missing for each new record. Only dataset variables are
> automatically retained; hence the result in Need2.
The way I understand what you say then the result of this code, shown
below, NUM=99 should only be on first obs from HAVE2, but that is not
the case. I don't know a good way to explain it but I don't think you
have either.
data need2;
retain flag 1;
set have(in=in1) have2(in=in2);
if in2 and flag then do;
num = 99;
flag = 0;
end;
run;
proc print data=need2;
run;
Obs flag num num2
1 1 1 .
2 1 3 .
3 0 99 4
4 0 99 5
|