How to capitalize the first letter of every word in a string
Capitalize the first letter of every word in a string Convert a text string into mixed case. Note: Beginning in SAS 9.1, this task is easily accomplished with the PROPCASE function. See Sample 2 on the Full Code tab. /* Sample 1: COMPBL, LOWCASE, SCAN, INDEX, UPCASE, SUBSTR */ data sample; input name $char50.; /* Lowercase the entire string, remove consecutive blanks */ newname= compbl ( lowcase (name)); length next $ 20; i=0; next=scan(newname,1, ' ' ); do while (next ne ' ' ); i+1; /* Scan off each 'word' based upon a space, locate the position */ /* of the first letter in the original string, UPCASE the first */ /* letter and use SUBSTR to replace the byte. */ pos= indexw (newname,trim(next)); substr (newname,pos,1)= upcase ( substr (newname,pos,1)); next= scan (newname,i, ' ' ); end; keep name newname; datalines; Jane DOE min ning chou HENRIK HANSSON D ETCHEVERRY, Charo B ; proc print ; run; /* Sample 2: PROPCASE (available in SAS 9.1) */...