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
31
32
33
34
35
36
37
38
39
40
41
42
*Convert 1st letter of each Word to Upper Case 
	and the rest of sting to lower case.

* Posted to SPSSX-L by Raynald Levesque on 2002/02/21.

DATA LIST  FIXED /a1 1-30 (a).
BEGIN DATA.
248 n. delphia ave.
9273 FAIRVEW dr. apt 410 e
6324 Meadowview
corner of south & maine
aaaaaaaaaaaa bbbbbbbbbbbbbbbbbbbbb
aaa bbb ccc ddd eee fff ggg hh
bb
END DATA.


*/////////////////.
DEFINE !capital (str=!CMDEND)
STRING a(A255).
VARIABLE WIDTH a(35).
COMPUTE a=LOWER(LTRIM(!str)).
COMPUTE SUBSTR(a,1,1)=UPCASE(SUBSTR(a,1,1)).
COMPUTE #idx=INDEX(a," ").
COMPUTE #delta=1.

lOOP IF #idx>0 &
	LENGTH(RTRIM(SUBSTR(a,#idx)))>0 & 
	#delta > 0.
COMPUTE SUBSTR(a,#idx+1,1)=UPCASE(SUBSTR(a,#idx+1,1)).
COMPUTE #delta = INDEX(SUBSTR(RTRIM(a),#idx + 1)," ").
COMPUTE #idx = #idx + #delta.
END LOOP.
!ENDDEFINE.
*/////////////////.

!capital str=a1.
EXECUTE.
LIST.

*** This could be generalized to handle many 
	variables at the same time.