|Date: ||Fri, 19 Jan 2007 11:00:04 -0500|
|Reply-To: ||Jack Clark <JClark@CHPDM.UMBC.EDU>|
|Sender: ||"SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>|
|From: ||Jack Clark <JClark@CHPDM.UMBC.EDU>|
|Subject: ||Re: implicit retain?|
Your question stated "The variable var2 inherits the value "d" from the
observation previous." I would suggest that you are confusing your input
observations from your output observations. Your data step is creating
multiple output observations per iteration (at least during the last input
observation), but SAS still sees input observation #3 where end=last as a
To resolve this issue, you could assign var2 = " ".
Center for Health Program Development and Management
University of Maryland, Baltimore County
From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of David
Sent: Friday, January 19, 2007 10:35 AM
Subject: implicit retain?
I have a fairly easy data step question regarding the retention of values
from one observation to the next. My question is this: why do values get
retained in a situation like this when explicit outputs are used after
another data set has been set. My expectation was that the data vector
would be reset to missing for both variables prior to the processing for
the last observation and that only var1, which was assigned a value (5),
would be non-missing in the last observation. The variable var2 inherits
the value "d" from the observation previous.
input var1 var2 $;
set test end=last;
if last then do;
/*no var2 assignment here*/
Obs var1 var2
1 1 a
2 2 b
3 3 c
4 4 d
5 5 d <---?
Could it be that the program data vector only gets reset when processing
returns to the top of the data step?
Anyone care to kick start my brain on this one?