Date: Wed, 11 Mar 2009 07:26:12 -0500
Reply-To: "./ ADD NAME=Data _null_;" <iebupdte@GMAIL.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: "./ ADD NAME=Data _null_;" <iebupdte@GMAIL.COM>
Subject: Re: convert alpha to number for phone
In-Reply-To: <gp87td$vhm$1@news.motzarella.org>
Content-Type: text/plain; charset=ISO-8859-1
I suggest you TRANSLATE the character to numbers then read number
string into numeric var and format with PICTURE.
proc format;
picture phone other='0-000-999-9999';
run;
data phone;
input phone:$upcase11.;
length tnum $11;
tnum = translate(phone,
'222','ABC',
'333','DEF',
'444','GHI',
'555','JKL',
'666','MNO',
'7777','PQRS',
'888','TUV',
'99999','WXYZ');
nnum = input(tnum,f11.);
format nnum phone.;
cards;
1CALLUSNOW
800THISNUM
1888THETALK
;;;;
run;
proc print;
run;
On 3/11/09, mo <mo@ju.cn> wrote:
> for example, take the phone number 1CALLUSNOW or 800THISNUM
>
> I can proc format my way around the 3-letters to 1-digit conversion if no
> function
> exists to perform same
>
|