<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: make only first letter capital in a sentence in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/make-only-first-letter-capital-in-a-sentence/m-p/437923#M109132</link>
    <description>&lt;P&gt;Then you will have to loop over each "sentance" and do what I present.&amp;nbsp; For example:&lt;/P&gt;
&lt;PRE&gt;data want (keep=x);
  x="i have an exercise, i  have to  find a solution?  i am tired !";
  flag=1;
  do i=1 to lengthn(x);
    if char(x,i) in (",","?","!") then flag=1;
    else if flag=1 and char(x,i) ne " " then do;
      substr(x,i,1)=upcase(char(x,i));
      flag=0;
    end;
  end;
run;&lt;/PRE&gt;</description>
    <pubDate>Fri, 16 Feb 2018 09:51:25 GMT</pubDate>
    <dc:creator>RW9</dc:creator>
    <dc:date>2018-02-16T09:51:25Z</dc:date>
    <item>
      <title>make only first letter capital in a sentence</title>
      <link>https://communities.sas.com/t5/SAS-Programming/make-only-first-letter-capital-in-a-sentence/m-p/437909#M109123</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Data solution; 
 SET exercice; 
length var1 $200; 
length b $1; 
 var1= UPCASE(substr(x,1,1)); 
 Do i=2 to length (x); 
 if substr (x, i, 1) in (".", "?", "!")
 then b=UPCASE (substr(x, i+2 , 1)); 
 else b=substr(x,i,1);
 var1= var1 || b;
 end;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Hello,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please, any one has an idea about how to handle this situation (the code I tried does not work) ;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to find a way to&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;make only first letter capital (in each sentence&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/STRONG&gt;in variable "X"&lt;STRONG&gt;)&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Data exercise;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;BR /&gt;x= "i have an exercise, i&amp;nbsp; have to&amp;nbsp; find a solution?&amp;nbsp; i am tired !" ;&lt;/P&gt;&lt;P&gt;y="Life is beautiful. I like my family"&lt;BR /&gt;RUN;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks !&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Data solution; 
 SET exercice; 
length var1 $200; 
length b $1; 
 var1= UPCASE(substr(x,1,1)); 
 Do i=2 to length (x); 
 if substr (x, i, 1) in (".", "?", "!")
 then b=UPCASE (substr(x, i+2 , 1)); 
 else b=substr(x,i,1);
 var1= var1 || b;
 end;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 16 Feb 2018 08:54:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/make-only-first-letter-capital-in-a-sentence/m-p/437909#M109123</guid>
      <dc:creator>hawari</dc:creator>
      <dc:date>2018-02-16T08:54:35Z</dc:date>
    </item>
    <item>
      <title>Re: make only first letter capital in a sentence</title>
      <link>https://communities.sas.com/t5/SAS-Programming/make-only-first-letter-capital-in-a-sentence/m-p/437912#M109125</link>
      <description>&lt;P&gt;If its just character 1 in each observation then:&lt;/P&gt;
&lt;PRE&gt;data solution;
  set exercice;
  substr(x,1,1)=upcase(substr(x,1,1));
run;&lt;/PRE&gt;
&lt;P&gt;The substr on the left means it is to be assigned the value on the right, and we only look at the first char and length 1.&amp;nbsp; The right upcases this same variable, then assigns it to the left.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you wanted all words upcase fist letter, then use the propcase() function.&lt;/P&gt;
&lt;P&gt;&lt;A href="http://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a002598106.htm" target="_blank"&gt;http://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a002598106.htm&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 16 Feb 2018 09:11:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/make-only-first-letter-capital-in-a-sentence/m-p/437912#M109125</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2018-02-16T09:11:50Z</dc:date>
    </item>
    <item>
      <title>Re: make only first letter capital in a sentence</title>
      <link>https://communities.sas.com/t5/SAS-Programming/make-only-first-letter-capital-in-a-sentence/m-p/437920#M109130</link>
      <description>&lt;P&gt;Thanks RW9 for your reply!&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What I want to do is : Make only letter capital in &lt;STRONG&gt;each sentence. &lt;/STRONG&gt;So, I want to have as OUTPUT for variable "X";&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;I&lt;/STRONG&gt;&lt;/FONT&gt; have an exercise, &lt;STRONG&gt;&lt;FONT color="#FF0000"&gt;I&lt;/FONT&gt;&amp;nbsp;&lt;/STRONG&gt; have to&amp;nbsp; find a solution?&amp;nbsp; &lt;STRONG&gt;&lt;FONT color="#FF0000"&gt;I&lt;/FONT&gt;&amp;nbsp;&lt;/STRONG&gt;am tired !" ;&lt;/P&gt;</description>
      <pubDate>Fri, 16 Feb 2018 09:39:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/make-only-first-letter-capital-in-a-sentence/m-p/437920#M109130</guid>
      <dc:creator>hawari</dc:creator>
      <dc:date>2018-02-16T09:39:41Z</dc:date>
    </item>
    <item>
      <title>Re: make only first letter capital in a sentence</title>
      <link>https://communities.sas.com/t5/SAS-Programming/make-only-first-letter-capital-in-a-sentence/m-p/437923#M109132</link>
      <description>&lt;P&gt;Then you will have to loop over each "sentance" and do what I present.&amp;nbsp; For example:&lt;/P&gt;
&lt;PRE&gt;data want (keep=x);
  x="i have an exercise, i  have to  find a solution?  i am tired !";
  flag=1;
  do i=1 to lengthn(x);
    if char(x,i) in (",","?","!") then flag=1;
    else if flag=1 and char(x,i) ne " " then do;
      substr(x,i,1)=upcase(char(x,i));
      flag=0;
    end;
  end;
run;&lt;/PRE&gt;</description>
      <pubDate>Fri, 16 Feb 2018 09:51:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/make-only-first-letter-capital-in-a-sentence/m-p/437923#M109132</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2018-02-16T09:51:25Z</dc:date>
    </item>
    <item>
      <title>Re: make only first letter capital in a sentence</title>
      <link>https://communities.sas.com/t5/SAS-Programming/make-only-first-letter-capital-in-a-sentence/m-p/437926#M109134</link>
      <description>&lt;P&gt;Thanks RW9 !!!!!&lt;/P&gt;&lt;P&gt;It works very well !&lt;/P&gt;</description>
      <pubDate>Fri, 16 Feb 2018 09:58:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/make-only-first-letter-capital-in-a-sentence/m-p/437926#M109134</guid>
      <dc:creator>hawari</dc:creator>
      <dc:date>2018-02-16T09:58:23Z</dc:date>
    </item>
    <item>
      <title>Re: make only first letter capital in a sentence</title>
      <link>https://communities.sas.com/t5/SAS-Programming/make-only-first-letter-capital-in-a-sentence/m-p/438066#M109187</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/193784"&gt;@hawari&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;Thanks RW9 for your reply!&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What I want to do is : Make only letter capital in &lt;STRONG&gt;each sentence. &lt;/STRONG&gt;So, I want to have as OUTPUT for variable "X";&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#ff0000"&gt;&lt;STRONG&gt;I&lt;/STRONG&gt;&lt;/FONT&gt; have an exercise, &lt;STRONG&gt;&lt;FONT color="#ff0000"&gt;I&lt;/FONT&gt;&amp;nbsp;&lt;/STRONG&gt; have to&amp;nbsp; find a solution?&amp;nbsp; &lt;STRONG&gt;&lt;FONT color="#ff0000"&gt;I&lt;/FONT&gt;&amp;nbsp;&lt;/STRONG&gt;am tired !" ;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Do any of your sentences contain numeric values such as 23.4 or $123.45? Or URLs such as &lt;A href="http://www.somesite.com" target="_blank"&gt;www.somesite.com&lt;/A&gt;? or emails? or acronyms or abbreviations (I.B.M.&amp;nbsp;&amp;nbsp; Mr. Dr. Mrs. Jr. )?&lt;/P&gt;
&lt;P&gt;These are instances of "period" not ending a sentence.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also note that your example text contains exactly 0 periods: comma, question mark and exclamation but no period. Depending on exact content you can't rely on ! or ? to end sentences either.&lt;/P&gt;
&lt;P&gt;If you can provide a rule that always works for your data to identify a sentence that can likely be programmed but be prepared for exceptions to cause unexpected output. OR to find things incorrectly capitalized because someone did that on data entry.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Identifying "sentence" from text is not a trivial exercise which is one reason text analytics systems exist and are somewhat pricey.&lt;/P&gt;</description>
      <pubDate>Fri, 16 Feb 2018 20:29:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/make-only-first-letter-capital-in-a-sentence/m-p/438066#M109187</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2018-02-16T20:29:13Z</dc:date>
    </item>
  </channel>
</rss>

