| Date: | Thu, 7 Jul 2011 13:19:10 -0400 |
| Reply-To: | Gerhard Hellriegel <gerhard.hellriegel@T-ONLINE.DE> |
| Sender: | "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU> |
| From: | Gerhard Hellriegel <gerhard.hellriegel@T-ONLINE.DE> |
| Subject: | Re: ASCII text into unique numeric: |
|---|
seems that it will not deal with the generated number with blanks in
between:
x=compress("%texttonum(text=aabbcc)");
Gerhard
On Thu, 7 Jul 2011 11:54:44 -0500, Joe Matise <snoopy369@GMAIL.COM> wrote:
>Not that I'm aware of, though you could pretty easily write one in PROC
>FCMP, or even in a macro. I wrote one that almost works, but doesn't
quite
>seem to - I'd be curious to find out why this is erroring (it seems to
error
>when the numbers are returned back to SAS, but that doesn't make sense to
>me).
>
>-Joe
>
>options mprint mlogic symbolgen;
>%macro texttonum(text=);
>%do _i = 1 %to
>%sysfunc(length(&text));%eval(%sysfunc(rank(%substr(&text,&_i,1)))-96)
>%end;
>%mend texttonum;
>data test;
>x=%texttonum(text=aabbcc);
>put x=;
>run;
>
>
>
>On Thu, Jul 7, 2011 at 11:36 AM, Aldi Kraja <aldi@wustl.edu> wrote:
>
>> Hi,
>>
>> I want to compare similarity among two strings, but my strings are in
>> letters and I want to transform them into unique numbers first before I
>> continue with similarity comparisons.
>>
>> Is there any function in SAS that transforms ASCII text string into a
>> numeric vector, where each letter based on ASCII order transforms into a
>> unique number, for example a -> 1, b ->2, c->3 and s.o.
>> So if I have a string of aaaabbcccc transforms into: 1111223333
>>
>> TIA,
>>
>> Aldi
>>
|