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 (March 1996, week 2)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Thu, 14 Mar 1996 18:14:49 PST
Reply-To:     TWB2%Rates%FAR@GO50.COMP.PGE.COM
Sender:       "SAS(r) Discussion" <SAS-L@UGA.CC.UGA.EDU>
From:         TWB2%Rates%FAR@GO50.COMP.PGE.COM
Subject:      Re: Implicit Retention

Mea culpa. As I said when Kernon called me privately on implicit retention, "that worries me Kernon, because when we disagree I usually believe you!"

Was the SAS-L award renamed Usually Noteworthy In eXplanations in his honor (it's rather cruel to make him wear a shirt with MVS on it)?

Tim Berryhill - Contract Programmer and General Wizard TWB2@PGE.COM or http://www.lookup.com/Homepages/92062/home.html Frequently at Pacific Gas & Electric Co., San Francisco The correlation coefficient between their views and my postings is slightly less than 0 ----------------------[Reply - Original Message]----------------------

Sent by:West Addison <MPRNJ!JWA@MPRNJ.COM> In February John Whittington <johnw@MAG-NET.CO.UK> posted the following message to SAS-L:

>>data both; >> retain t1-t5; >> if _n_=1 then set b; >> set a; >Geoff, you don't actually even need the RETAIN; it is implicit in >'SET b'; all variables in datasets which are SET are automatically >RETAINed.

Tim Berryhill <TWB2@PGE.COM> posted the following reply, which apparently went unchallenged:

>In 5.x, the explicit RETAIN is required. In 6.08, the RETAIN >is implied by the SET (this saves the overhead of setting to >missing, but leads to some surprising code when you have a 5.18 >mind and put statements before the SET statement). I THINK 6.06 >required explicit retention and the implicit retention was a >side effect of the performance enhancements in 6.07. > >Tim Berryhill - Contract Programmer and General Wizard

Tim's assertion seemed wrong to me--my recollection is that variables read in SET statements have been implicitly retained in every version of SAS I've ever used, going back to version 5-point-something. To make sure that my memory was not failing me, I went back and checked the manuals. Here's what I found.

From "SAS Language: Reference, Version 6, First Edition", copyright 1990 (release 6.06), page 27: "When variables are read with a SET, MERGE, or UPDATE statement, the SAS system sets the values to missing only before the first iteration of the DATA step. (If a BY statement is present, the variable values are also set to missing when the BY group changes.) Thereafter, the variables retain their values until new values become available: for example, through an assignment statement or through the next execution of the SET, MERGE, or UPDATE statement."

From "SAS Language Guide for Personal Computers, Release 6.03 Edition", copyright 1988, page 22: "Variables read with a SET, MERGE, or UPDATE statement are retained."

From "SAS User's Guide: Basics, Version 5 Edition", copyright 1985, page 33: "Variables read with a SET, MERGE, or UPDATE statement are retained."

From "SAS User's Guide: Basics, 1982 Edition", copyright 1982, page 20: "(Variables read with a SET, MERGE, or UPDATE statement are retained.)"

It is evident from these excerpts that SAS has been consistent on this point since at least 1982. (The fuller description in the most recent manual does not signal a change in how the data step works, but is merely an elaboration of the way it has worked for quite some time.) Unless there was some version with a bug (which I would find rather unlikely in such a basic feature), I firmly believe that an explicit RETAIN statement has *never* been required in either version 5 or version 6 for variables read in from an existing SAS data set (as opposed to a raw data file). I would be interested in hearing if anyone has evidence to the contrary.

West Addison Mathematica Policy Research, Inc. Princeton, New Jersey JWA@MPRNJ.Com

=====================================================================


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