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 (December 2003, week 4)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Wed, 24 Dec 2003 14:47:04 -0500
Reply-To:     "Richard A. DeVenezia" <radevenz@IX.NETCOM.COM>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         "Richard A. DeVenezia" <radevenz@IX.NETCOM.COM>
Subject:      Re: Using RETAIN  to reorder with a Name Prefix list (colon
              specifica              tion)

"Chakravarthy, Venky" <Venky.Chakravarthy@PFIZER.COM> wrote in message news:303682BAB5176E47941169F3C8444778B1B6DE@anagrdexm03.research.aa.wl.com... > Hi, > > There have been several discussions on the list about reordering variables. > It is even on the SASware ballot. One of the popular methods discussed is to > use a RETAIN statement before the SET statement. > > I observed something today while using a RETAIN statement to reorder the > variables in a data set. When a name prefix list (such as a:) is used to > specify a range of variables those variables get put at the end even if they > were in the beginning in the original. Even worse, it seems to completely > ignore the specified relative order of such groups of variables. If the > original order is c: and a: and you want a: and c: and specify that in the > RETAIN, it is ignored. The original order is maintained. See below for a > simple illustration. Any explanations? Has this been covered before? snip > > Venky Chakravarthy

in: c1 c2 a1 a2 b

retain a: b c: ; set foo;

out: b c1 c2 a1 a2

This is totally my expectation, and hope fully others.

At the compile time step prior to the retain statement there are no pdv variables.

a: b c: -> after the retain statement the compiler knows there is a variable named b (possibly) and possibly variables whose names start with a and variables whose names start with c.

at the set statment the compiler knows there are variables c1 c2 a1 a2 b

one must know infer that full formed variable names in a retain statement take ordering precedence, followed by the order of the incoming data vector. Since the a: and c: are not fully formed, the order of variables (in the pdv) matching the a: c: specification will be the same as the incoming data set.

b - fully specified in retain c1 - matches c: of retain, order per incoming dv c2 - matches c: of retain , order per incoming dv a1 - matches a: of retain , order per incoming dv a2- matches a: of retain, order per incoming dv

-- Richard A. DeVenezia http://www.devenezia.com/downloads/sas/macros/?m=hash-macros


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