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
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
|