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 (November 2002, week 3)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:   Mon, 18 Nov 2002 14:00:02 -0800
Reply-To:   "Huang, Ya" <yhuang@AMYLIN.COM>
Sender:   "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:   "Huang, Ya" <yhuang@AMYLIN.COM>
Subject:   Re: A question on how to convert character variables
Comments:   To: Jialu Zhang <jzhang8@GL.UMBC.EDU>
Content-Type:   text/plain; charset="iso-8859-1"

Jialu,

Try translate:

13 data _null_; 14 str='ABCADABABB'; 15 nstr=translate(str,'1234','ABCD'); 16 put nstr=; 17 run;

nstr=1231412122

HTH

Ya Huang

-----Original Message----- From: Jialu Zhang [mailto:jzhang8@GL.UMBC.EDU] Sent: Monday, November 18, 2002 1:50 PM To: SAS-L@LISTSERV.UGA.EDU Subject: A question on how to convert character variables

Hello,

Could someone please help me on this?

I have a dataset like the following:

ABCADABABB ACDABADABC ...

How can I convert the character variable on each position into a numeric variable, for examle "A"=1, "B"=2, "C"=3 and "D"=4, so that my converted dataset will look like this.

(from position 1 to position 12)

1 2 3 1 4 1 2 1 2 2 1 3 4 1 2 1 4 1 2 3

Many thanks in advance.

Julie


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