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 (August 2000, week 1)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Tue, 1 Aug 2000 09:54:01 -0400
Reply-To:     Richard.Graham@INTELLICISIONS.COM
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         "Richard W. Graham" <Richard.Graham@INTELLICISIONS.COM>
Subject:      Re: Combine char variables
Comments: To: Antonio <wongantonio@HONGKONG.COM>
Content-type: multipart/mixed;
              Boundary="0__=9Cy4p6AkB9c9SvedRAQu3rC4x0LT7mhJsWoZ0PcaSkwEjCzW20Iaz8Up"

In a data step you could do the following:

data new(drop=firstname midname lastname); set old; fullname = lastname||","||firstname||" "||midname; run;

The || is the concatenation operator;

If there are extra spaces at the end of each variable that you want to remove, you could use the compress function as in:

fullname = compress(lastname)||","||compress(firstname)||" "||midname;

Be careful, however, because this function will remove ALL spaces within the variable. To avoid that use the trim(left(lastname)) etc.

Richard W. Graham Senior Consultant, Technology Delivery Intellicisions Data Inc. 2000 Regency Parkway, Suite 355 Cary, NC 27511 (919) 467-0505 (Embedded image moved to file: pic19488.gif)

Antonio <wongantonio@HON To: SAS-L@LISTSERV.UGA.EDU GKONG.COM> cc: (bcc: Richard Graham/Tech/Intellicisions) Sent by: "SAS(r) Subject: Combine char variables Discussion" <SAS-L@LISTSERV. UGA.EDU>

08/01/00 09:39 AM Please respond to Antonio

Hi Friends,

Suppose I have 3 char variables: Firstname Midname Lastname

I want to combine the 3 into 1 single variable Which char function I should use ? Thank you very much in advance.


pic19488.gif [image/gif]


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