<?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 Capitalize first word after a dash only if there is a dash. Help! in SAS Viya</title>
    <link>https://communities.sas.com/t5/SAS-Viya/Capitalize-first-word-after-a-dash-only-if-there-is-a-dash-Help/m-p/958231#M2747</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I need to capitalize the first letter of the word &lt;STRONG&gt;if&lt;/STRONG&gt; there is a dash. So in image above, 'Construction -industrial' should be 'Construction - Industrial'.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="dmen24_0-1738696489426.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/104339i9390D4B2220DA8EA/image-size/medium?v=v2&amp;amp;px=400" role="button" title="dmen24_0-1738696489426.png" alt="dmen24_0-1738696489426.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Here is my code:&amp;nbsp;&lt;/P&gt;&lt;P&gt;Concatenate(UpCase(Substring('Industry_Desc'n, 1, 1)),&lt;BR /&gt;LowerCase(Substring('Industry_Desc'n, 2, 1000)))&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can someone help?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;</description>
    <pubDate>Tue, 04 Feb 2025 19:17:12 GMT</pubDate>
    <dc:creator>dmen24</dc:creator>
    <dc:date>2025-02-04T19:17:12Z</dc:date>
    <item>
      <title>Capitalize first word after a dash only if there is a dash. Help!</title>
      <link>https://communities.sas.com/t5/SAS-Viya/Capitalize-first-word-after-a-dash-only-if-there-is-a-dash-Help/m-p/958231#M2747</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I need to capitalize the first letter of the word &lt;STRONG&gt;if&lt;/STRONG&gt; there is a dash. So in image above, 'Construction -industrial' should be 'Construction - Industrial'.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="dmen24_0-1738696489426.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/104339i9390D4B2220DA8EA/image-size/medium?v=v2&amp;amp;px=400" role="button" title="dmen24_0-1738696489426.png" alt="dmen24_0-1738696489426.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Here is my code:&amp;nbsp;&lt;/P&gt;&lt;P&gt;Concatenate(UpCase(Substring('Industry_Desc'n, 1, 1)),&lt;BR /&gt;LowerCase(Substring('Industry_Desc'n, 2, 1000)))&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can someone help?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Tue, 04 Feb 2025 19:17:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Viya/Capitalize-first-word-after-a-dash-only-if-there-is-a-dash-Help/m-p/958231#M2747</guid>
      <dc:creator>dmen24</dc:creator>
      <dc:date>2025-02-04T19:17:12Z</dc:date>
    </item>
    <item>
      <title>Re: Capitalize first word after a dash only if there is a dash. Help!</title>
      <link>https://communities.sas.com/t5/SAS-Viya/Capitalize-first-word-after-a-dash-only-if-there-is-a-dash-Help/m-p/958287#M2748</link>
      <description>&lt;P&gt;Please provide more sample data together with desired result via a SAS data step.&lt;/P&gt;</description>
      <pubDate>Tue, 04 Feb 2025 22:37:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Viya/Capitalize-first-word-after-a-dash-only-if-there-is-a-dash-Help/m-p/958287#M2748</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2025-02-04T22:37:55Z</dc:date>
    </item>
    <item>
      <title>Re: Capitalize first word after a dash only if there is a dash. Help!</title>
      <link>https://communities.sas.com/t5/SAS-Viya/Capitalize-first-word-after-a-dash-only-if-there-is-a-dash-Help/m-p/958295#M2749</link>
      <description>&lt;P&gt;It is impossible to code from pictures. So let's use the values you put into your question body instead.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Construction -industrial
Construction - Industrial&lt;/CODE&gt;&lt;/PRE&gt;
&lt;UL&gt;
&lt;LI&gt;Do you also want to insert that space after the hyphen?&lt;/LI&gt;
&lt;LI&gt;What if there is already a space after the hyphen? Do you want to find the next non-space,non-hyphen character and upcase that?&lt;/LI&gt;
&lt;LI&gt;Is it possible your text has non-ASCII characters, like an endash or emdash, instead of a hyphen. Do you need to find those also?&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;So assuming that the hyphen is immediately in front of the character to upcase you could try something like this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  set have;
  loc=-1;
  do until(loc=0);
    loc=findc(string,'-',loc+2);
    if loc then substr(string,loc+1,1)=upcase(char(string,loc+1));
  end;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Which is almost exactly like the first example in the &lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/lefunctionsref/n1mdh2gvd5potjn14jipysvzn4o7.htm#n17krnzr8j8qwan1dlrvvthqpzox" target="_self"&gt;FINDC() documentation&lt;/A&gt;.&lt;/P&gt;
&lt;P&gt;Not hard to adjust to skip over spaces after the hyphen.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  set have;
  loc=0;
  do until(loc=0);
    loc=findc(string,'-',loc+1);
    if loc then loc=findc(string,'- ',loc+1,'k');
    if loc then substr(string,loc,1)=upcase(char(string,loc));
  end;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 05 Feb 2025 01:47:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Viya/Capitalize-first-word-after-a-dash-only-if-there-is-a-dash-Help/m-p/958295#M2749</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2025-02-05T01:47:43Z</dc:date>
    </item>
    <item>
      <title>Re: Capitalize first word after a dash only if there is a dash. Help!</title>
      <link>https://communities.sas.com/t5/SAS-Viya/Capitalize-first-word-after-a-dash-only-if-there-is-a-dash-Help/m-p/958297#M2750</link>
      <description>&lt;P&gt;If below doesn't return what you're after then please provide representative sample data that shows have and want.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
	infile datalines truncover dsd dlm=',';
	input have_str:$60. want_str:$60.;
	datalines;
Construction - industrial sector ,Construction - Industrial sector
Construction - INDUSTRIAL sector ,Construction - INDUSTRIAL sector
Industrial construction ltd      ,Industrial construction ltd
;
run;

data want;
	set have;
	length derived_string $60;
	derived_string=prxchange('s/(- *)([a-z])/$1\u$2/', -1, trim(have_str));
run;

proc print data=want;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Patrick_0-1738718324331.png" style="width: 677px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/104347i150A3D485406A997/image-dimensions/677x105?v=v2" width="677" height="105" role="button" title="Patrick_0-1738718324331.png" alt="Patrick_0-1738718324331.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 05 Feb 2025 01:20:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Viya/Capitalize-first-word-after-a-dash-only-if-there-is-a-dash-Help/m-p/958297#M2750</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2025-02-05T01:20:12Z</dc:date>
    </item>
  </channel>
</rss>

