[prev in list] [next in list] [prev in thread] [next in thread] 

List:       sas-l
Subject:    Re: UPPERCASE THE FIRST LETTER OF EVERY WORD
From:       "Gregg P. Snell" <gsnell () DATASAVANTCONSULTING ! COM>
Date:       2001-05-31 16:42:52
[Download RAW message or body]

SAS-L'ers,

Ian was kind enough to point out a subtle yet potentially serious omission
from my earlier post.  You may find it interesting, as I did, to simply run
the code Ian provided below to see what happens when you do not specify the
separators for the SCAN function.

To correct the omission, replace each occurrence of SCAN(A,I) with
SCAN(A,I,' ') and rerun the test.

Thanks Ian!

----- Original Message -----
From: Ian Whitlock <WHITLOI1@WESTAT.com>
To: 'Gregg P. Snell' <gsnell@datasavantconsulting.com>
Sent: Thursday, May 31, 2001 11:24 AM
Subject: RE: UPPERCASE THE FIRST LETTER OF EVERY WORD


Gregg,

You might try a better test.

data _null_;
  length a b $70;
  a='oops! I forgot to limit the separators #%&*., and lost the period.';
  b=' ';
  a=trim(a);
  words=length(a)-length(compress(a))+1;
  put words=;
  do i=1 to words;
     b=trim(b) || ' ' || upcase(substr(scan(a,i),1,1));
     if length(scan(a,i)) > 1 then b=trim(b) ||
                        lowcase(substr(scan(a,i),2));
  end;
  put a=;
  put b=;
run;

Ian Whitlock <whitloi1@westat.com>

-----Original Message-----
From: Gregg P. Snell [mailto:gsnell@DATASAVANTCONSULTING.COM]
Sent: Thursday, May 31, 2001 12:07 PM
To: SAS-L@LISTSERV.UGA.EDU
Subject: Re: UPPERCASE THE FIRST LETTER OF EVERY WORD


Jose,

Here is one example...

data _null_;
  length a b $40;
  a='THIS IS A TEST SENTENCE';
  b=' ';
  a=trim(a);
  words=length(a)-length(compress(a))+1;
  put words=;
  do i=1 to words;
     b=trim(b) || ' ' || upcase(substr(scan(a,i),1,1));
     if length(scan(a,i)) > 1 then b=trim(b) ||
                        lowcase(substr(scan(a,i),2));
  end;
  put a=;
  put b=;
run;

Gregg P. Snell
Data Savant Consulting
(913) 638-4640
http://www.datasavantconsulting.com

Co-chair of MWSUG 2001
http://www.mwsug.org/mw_2001/index.htm


José Ailton Alencar Andrade <andrade@INEP.GOV.BR> wrote in message
news:3B166709.A12B8017@inep.gov.br...
>     Hi!
>
>     How do I uppercase the first letter in every work in a string
> variable?
>
>     thanks.
>     Ailton.
>
>
>

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic