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 2008, week 3)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Wed, 20 Feb 2008 13:23:14 -0500
Reply-To:     Dave Scocca <dave@SCOCCA.ORG>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         Dave Scocca <dave@SCOCCA.ORG>
Subject:      Re: Parsing a Character Variable
Comments: To: "Smith, Curtis, Mr, DCAA" <Curtis.Smith@DCAA.MIL>
In-Reply-To:  <0DCF1675A5DEAA408C85CE05207539C302FCAE6A@DCAA0203.dcaa.mil>
Content-Type: text/plain; charset=us-ascii; format=flowed

--On 2/20/2008 12:08 PM -0600 Smith, Curtis, Mr, DCAA wrote:

> Unfortunately for me, I am no longer paid to program SAS (boo), but still > use it to get the job done. That being the case, I don't have time on the > clock to solve a problem, and thus need your help. I have a SAS data set > containing a character variable that contains an employee number, last > name, first initial, and middle initial stored in a contiguous string in > the following form: > > employee number,colon delimiter,last name,comma delimiter,first > initial,comma delimiter,middle initial > > For example: > > 12345:SMITH,C,A > > I want to parse this into four separate character variables (employee > number, last name, first initial, and middle initial).

SCAN() function, with specified delimiters.

empNum=scan(theString, 1, ':,') ; lastName=scan(theString, 2, ':,') ; firstInit=scan(theString, 3, ':,') ; middleInit=scan(theString, 4, ':,') ;

Dave Scocca


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