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 (February 1996, week 2)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Wed, 14 Feb 1996 18:15:05 -0800
Reply-To:     Karsten Self <karsten@NEWAGE1.STANFORD.EDU>
Sender:       "SAS(r) Discussion" <SAS-L@UGA.CC.UGA.EDU>
From:         Karsten Self <karsten@NEWAGE1.STANFORD.EDU>
Subject:      Re: How to merge a data set?
Comments: To: John Whittington <johnw@MAG-NET.CO.UK>
In-Reply-To:  <199602150150.BAA10236@mag-net.co.uk>

I've been strenuously trying to avoid this debate, but...

Could it be that you are arguing the wrong side of the coin.

It isn't that variables from a given dataset are retained, it's that the dataset vector (DSV) for a conditionally SET dataset is not *initialized* for the data step loops in which it the dataset is not SET.

I posit the following:

---------------------------------------------------------------------------- data one; input a b c; cards; 1 11 21 2 12 22 3 13 23 4 14 24 5 15 25 6 16 26 7 17 27 8 18 28 9 19 29 ; run;

data two; input aa bb cc; cards; 101 111 121 102 112 122 103 113 123 ;

data three; input x y z; cards; 201 202 203 ; run;

data four; input xx yy zz; datalines; 301 311 321 302 312 322 303 313 323 ; run;

data whoami; set one; if ((_n_ eq 1 or a = 8)) then set two;

if "black" eq "white" then set three;

if a eq 4 then set four;

run;

proc print data= whoami; run;

---------------------------------------------------------------------------- The SAS System 3 17:22 Wednesday, February 14, 1996

OBS A B C AA BB CC X Y Z XX YY ZZ

1 1 11 21 101 111 121 . . . . . . 2 2 12 22 101 111 121 . . . . . . 3 3 13 23 101 111 121 . . . . . . 4 4 14 24 101 111 121 . . . 301 311 321 5 5 15 25 101 111 121 . . . 301 311 321 6 6 16 26 101 111 121 . . . 301 311 321 7 7 17 27 101 111 121 . . . 301 311 321 8 8 18 28 102 112 122 . . . 301 311 321 9 9 19 29 102 112 122 . . . 301 311 321

On Thu, 15 Feb 1996, John Whittington wrote:

> On Sun, 11 Feb 1996, rcw@TENET.EDU wrote: > > >In <199602101218.MAA17947@mag-net.co.uk>, John Whittington > ><johnw@MAG-NET.CO.UK> writes:

> >You example works here because you have two different SET statements, both of > >which have their own Data Set Vector. It is the DSV which is reset on each > >execution, if they are executed The second SET is not executed - consequently > >it acts like a RETAIN.

> Richard, you have lost me here. The number of SET statements has no bearing > on whether or not any one of them 'acts like a RETAIN'. All variables which > appear in *any* SET statement in the DATA step are effectively RETAINed, as > per the quote from TFM in your other posting. That EVEN applies for a SET > statement which is NEVER executed, for example: > > data three; > set one; > if 3=4 then set two; /* never executed */ > if _n_=1 then f=999; /* f is one of the variables in datset two */ > run; >

--------------------------------------------- Karsten M. Self -- Sr. SAS Programmer/Analyst Sierra Information Services, Inc. Contracting for NBER at Stanford University

Karsten@newage1.Stanford.EDU KMSelf@ix.netcom.com

What part of gestalt don't you understand?


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