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 (June 2002, week 4)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Wed, 26 Jun 2002 14:23:53 -0400
Reply-To:     "Huang, Ya" <ya.huang@PFIZER.COM>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         "Huang, Ya" <ya.huang@PFIZER.COM>
Subject:      Re: Unwanted retain, how to turn it off?
Content-Type: text/plain

Never mind, I just figure it out. The idea is to introduce a temp var:

data ab; merge a b; by byv; y=z+x; drop x; rename y=z;

-----Original Message----- From: Huang, Ya Sent: Wednesday, June 26, 2002 11:20 AM To: SAS-L@LISTSERV.UGA.EDU Subject: Unwanted retain, how to turn it off?

Hi there,

Take a look at the following code:

data a; input byv x; cards; 9 1 9 2 9 3 9 4 9 5 ;

data b; input byv z; cards; 9 5 ;

data ab; merge a b; by byv; z=z+x;

options nocenter; proc print; run;

------------- Obs byv x z

1 9 1 6 2 9 2 8 3 9 3 11 4 9 4 15 5 9 5 20

What I want is this:

Obs byv x z

1 9 1 6 2 9 2 7 3 9 3 8 4 9 4 9 5 9 5 10

I can achieve this by splitting the last data step to two:

data ab; merge a b; by byv;

data ab; set ab; z=z+x;

I wonder if I can do it in one step, meaning I need to turn off the default retain within a by group of merging. Is that possible?

Thanks

Ya Huang


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