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 2007, week 5)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Fri, 30 Mar 2007 10:36:58 +1000
Reply-To:     "Johnson, David" <David.Johnson@CBA.COM.AU>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         "Johnson, David" <David.Johnson@CBA.COM.AU>
Subject:      Re: select statement in data step
Content-Type: text/plain; charset="us-ascii"

I was following rule 2 Pete, and assuming the data were well understood.

The delimiter is a safe approach at the expense of another byte in the PDV and a little more memory, but I would never approach this situation without first verifying that CAMPAIGN was always 7 bytes and OUTAD always 3 bytes as shown.

Kind regards

David

The Moving Finger writes; and, having writ, Moves on: nor all your Piety nor Wit Shall lure it back to cancel half a Line, Nor all your Tears wash out a Word of it

Omar Khayyam (trans: Edward Fitzgerald)

-----Original Message----- From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of Peter Sent: Thursday, 29 March 2007 11:01 PM To: SAS-L@LISTSERV.UGA.EDU Subject: Re: select statement in data step

In this approach, I always recommend placing a delimiter between the pieces of the start variable, to allow blank compression without losing the uniqueness of the concatenation.

Even when the concatenation has a fixed structure as in David's posting below, I find the delimiters provide a useful reminder of the component boundaries. The catx() function does most of the work, and the dtYear. format provides the year from a datetime value. (of course, David would know these things ;-)

Data CNTLIN; > Set CLIENTS( Keep = CLIENT EVENT OUTCOME > Rename = ( OUTCOME = LABEL) ); length start $20 ; > Retain FMTNAME "FCltEvnt" > TYPE "C"; START = catx('#', CLIENT, Put( EVENT, DTYear. ) ); > Run;

PeterC

On Mar 29, 2:38 am, David.John...@CBA.COM.AU ("Johnson, David") wrote: > Yes you can reduce it using proc format. > > Faced with client ids that associated to annual events, and wanting to

> match the client/event to some other data, we built a format table by > concatenating as shown in the following untested sample code: > > Data CNTLIN; > Set CLIENTS( Keep = CLIENT EVENT OUTCOME > Rename = ( OUTCOME = LABEL) ); > Retain FMTNAME "FCltEvnt" > TYPE "C"; > START = Put( CLIENT, Z8.) || Put( DatePart( EVENT), Year4.); Run; > > CAMPAIGN and OUTAD are already strings, so it is simpler code. > > Kind regards > > David > > The Moving Finger writes; and, having writ, Moves on: nor all your > Piety nor Wit Shall lure it back to cancel half a Line, Nor all your > Tears wash out a Word of it > > Omar Khayyam (trans: Edward Fitzgerald) > > > > -----Original Message----- > From: SAS(r) Discussion [mailto:S...@LISTSERV.UGA.EDU] On Behalf Of > > Xiao Tang > Sent: Thursday, 29 March 2007 4:03 AM > To: S...@LISTSERV.UGA.EDU > Subject: Re: select statement in data step > > Well, but for the following code, how you code it by using select in a

> data step? I used select statement, seems still hard code, no way to > reduce it even using proc format. The reason I consider using select > because it is more efficient when the table have millions observation. > > if campaign ='0000540' and outad='010' then location='Philadelphia'; > else if campaign ='0000587' and outad='010' then > location='Philadelphia'; else if campaign ='0000540' and outad='012' > then location='Pittsburgh'; else if campaign ='0000587' and outad='012' > then location='Pittsburgh'; else if campaign ='0000540' and outad='007' > then location='Charlotte'; else location='Other'; > > Thanks, > > Xiao >

************** IMPORTANT MESSAGE ***************************** This e-mail message is intended only for the addressee(s) and contains information which may be confidential. If you are not the intended recipient please advise the sender by return email, do not use or disclose the contents, and delete the message and any attachments from your system. Unless specifically indicated, this email does not constitute formal advice or commitment by the sender or the Commonwealth Bank of Australia (ABN 48 123 123 124) or its subsidiaries. We can be contacted through our web site: commbank.com.au. If you no longer wish to receive commercial electronic messages from us, please reply to this e-mail by typing Unsubscribe in the subject line. **************************************************************


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