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