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 2001, week 4)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Tue, 27 Nov 2001 14:56:07 -0600
Reply-To:     Jonathan Goldberg <jonathan@MATLOCK.WUSTL.EDU>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         Jonathan Goldberg <jonathan@MATLOCK.WUSTL.EDU>
Subject:      Re: A Question on Name Clean
Comments: To: c674010@YAHOO.COM
Content-Type: TEXT/PLAIN; charset=US-ASCII

Jie Qin: I've made some changes in CAPS:

>data data_need_to_clean; >set my_sas_data; >array possible_suffix{33} $ _temporary_ (' I,' ',I,' >',I ' ', I ' ' II,' ',II,' ',II ' ', II ' 'III' ' IV,' >',IV,' ', IV ' ',IV ' '1V' ' V,' ',V,' ',V ' ', V ' ' >VI,' ',VI,' ', VI ' ',VI ' 'V1' 'VII' 'VIII' ' SR,' >',SR,' ',SR ' ', SR ' ' JR,' ',JR,' ',JR ' ', JR ' ); > > do i=1 to 33; > index=index(upcase(nbme_name),possible_suffix{i}); > if index then DO; /*SO AS NOT TO GET 33 COPIES OF EVERY HIT*/ > suffix=compress(TRIM(possible_suffix{i},', ')); /*REMOVE*/ /*TRAILING*/ > output; /*BLANKS*/ END; > end; >drop i; >run;

It seems that the default length of a character _temporary_ array element is 8. Therefore, the trim() is necessary for the comparison to succeed.

Also, I suggest you not play around with comma variants like ', II' and simply put variants in descending order. That is, order the array elements as 'III' 'II' 'I' so the search for 'I' won't find the first character of 'III'. Likewise for 'VII' and 'VI'.

Note that the regular expression functions are often often useful in this type of processing. Check the manual on the functions rxparse and rxmatch. SAS's regular expression syntax is strange, but powerful.

Jonathan Goldberg Missouri Alcoholism Research Center Dept. of Psychiatry Washington University School of Medicine 40 N. Kingshighway, Suite One St. Louis, MO 63108 314-286-2212


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