LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous messageNext messagePrevious in topicNext in topicPrevious by same authorNext by same authorPrevious page (January 2007, week 3)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
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?
Comments:   To: David Ryerson <ryersond@HOTMAIL.COM>
Content-Type:   text/plain

Dave,

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 single observation.

To resolve this issue, you could assign var2 = " ".

Jack Clark Research Analyst Center for Health Program Development and Management University of Maryland, Baltimore County

-----Original Message----- From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of David Ryerson Sent: Friday, January 19, 2007 10:35 AM To: SAS-L@LISTSERV.UGA.EDU 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.

data test; input var1 var2 $; cards; 1 a 2 b 3 c ;

data new; set test end=last; output; if last then do; var1=4; var2="d"; output; var1=5; /*no var2 assignment here*/ output; end; run;

proc print;run;

Results:

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?

Thanks, Dave


Back to: Top of message | Previous page | Main SAS-L page