Remove initial from name
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | * Removing initials from name. * posted to SPSSX-L by Ray on 2002/08/22. DATA LIST FIXED /str1 1-20(A). BEGIN DATA Jack Jeff V. Mark S John Luke W. Edmund T Edward Ed Ed L. END DATA. LIST. COMPUTE pos1=LENGTH(RTRIM(str1)). DO IF pos1 > 2. DO IF ANY(" ",SUBSTR(str1,pos1 -1,1),SUBSTR(str1,pos1 -2,1)). COMPUTE str1=SUBSTR(str1,1,pos1-2). END IF. END IF. COMPUTE pos2=INDEX(str1," "). DO IF pos2=2 OR (pos2=3 AND SUBSTR(str1,2,1)="."). COMPUTE str1=LTRIM(SUBSTR(str1,pos2 + 1)). END IF. EXECUTE. |
Related pages
...