<?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: Parsing CamelCase in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Parsing-CamelCase/m-p/272656#M54263</link>
    <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/52762"&gt;@JerryLeBreton&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;Using PRX functions looks inviting but this can also be done simply with:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;model =substr(vehicle, findc(vehicle, , &lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT face="Courier New" size="2" color="#008080"&gt;2&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt;, &lt;/FONT&gt;&lt;FONT face="Courier New" size="2" color="#800080"&gt;'SU'&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;));&lt;/FONT&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Good idea. One could apply the LEFT function to the result in order to avoid discrepancies like &lt;FONT face="courier new,courier"&gt;'Renegade'&lt;/FONT&gt; vs. &lt;FONT face="courier new,courier"&gt;'&amp;nbsp;Renegade'&lt;/FONT&gt;.&lt;/P&gt;</description>
    <pubDate>Tue, 24 May 2016 09:22:48 GMT</pubDate>
    <dc:creator>FreelanceReinh</dc:creator>
    <dc:date>2016-05-24T09:22:48Z</dc:date>
    <item>
      <title>Parsing CamelCase</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Parsing-CamelCase/m-p/272585#M54249</link>
      <description>&lt;P&gt;Using SAS 9.3, I am trying to parse a variable, &lt;EM&gt;Vehicle&lt;/EM&gt;,&amp;nbsp;of auto names written (mostly) in camel case. For example,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;JeepGrand Cherokee&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;JeepRenegade&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;JeepWrangler&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;...&lt;/EM&gt;other records not in camel case&lt;/P&gt;&lt;P&gt;&lt;EM&gt;Jeep Renegade&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&amp;nbsp;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;I'd like to define a new&amp;nbsp;variable,&amp;nbsp;&lt;EM&gt;Model&lt;/EM&gt;, containing the model names of the vehicles. For the records separating make from model with a space, I have a solution using the&amp;nbsp;&lt;FONT face="courier new,courier"&gt;findw&lt;FONT face="arial,helvetica,sans-serif"&gt; function:&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;if findw(Vehicle, "Renegade") then Vehicle2 = "Renegade"&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="arial,helvetica,sans-serif"&gt;This does not work for the camel case records. One solution I have worked out is to use a combination of the&amp;nbsp;&lt;FONT face="courier new,courier"&gt;scan&lt;FONT face="arial,helvetica,sans-serif"&gt; and &lt;FONT face="courier new,courier"&gt;tranwrd&lt;/FONT&gt; function.&amp;nbsp;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;if findw(strip(tranwrd(scan(Vehicle, 1, " "), "Jeep", " ")), "Wrangler") then Vehicle2 = "Wrangler"&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="arial,helvetica,sans-serif"&gt;This works because I have a small number of makes in the data set. But how could I generalize this parsing to a larger list of automakers? In general, can we specify "case" as a delimiter in any character functions?&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="arial,helvetica,sans-serif"&gt;I appreciate any feed back anyone can provide.&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="arial,helvetica,sans-serif"&gt;Dhrumil Patel&lt;/FONT&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;&lt;FONT face="courier new,courier"&gt;&lt;FONT face="arial,helvetica,sans-serif"&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 24 May 2016 00:06:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Parsing-CamelCase/m-p/272585#M54249</guid>
      <dc:creator>dhrumil_patel</dc:creator>
      <dc:date>2016-05-24T00:06:02Z</dc:date>
    </item>
    <item>
      <title>Re: Parsing CamelCase</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Parsing-CamelCase/m-p/272589#M54252</link>
      <description>&lt;P&gt;There's going to be a PRX function that's much more efficient, but you can use the ANYUPPER()/SUBSTR() function.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
input details $32.;
x=anyupper(details, 2);
make=substr(details, 1, x-1);
model=substr(details, x);
cards;
JeepGrand Cherokee
JeepRenegade
JeepWrangler
;
run;

proc print data=want;run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 24 May 2016 01:02:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Parsing-CamelCase/m-p/272589#M54252</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-05-24T01:02:50Z</dc:date>
    </item>
    <item>
      <title>Re: Parsing CamelCase</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Parsing-CamelCase/m-p/272592#M54254</link>
      <description>&lt;P&gt;Using PRX functions looks inviting but this can also be done simply with:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;model =substr(vehicle, findc(vehicle, , &lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;2&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt;, &lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="2"&gt;'SU'&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;));&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 24 May 2016 01:12:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Parsing-CamelCase/m-p/272592#M54254</guid>
      <dc:creator>JerryLeBreton</dc:creator>
      <dc:date>2016-05-24T01:12:32Z</dc:date>
    </item>
    <item>
      <title>Re: Parsing CamelCase</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Parsing-CamelCase/m-p/272656#M54263</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/52762"&gt;@JerryLeBreton&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;Using PRX functions looks inviting but this can also be done simply with:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;model =substr(vehicle, findc(vehicle, , &lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT face="Courier New" size="2" color="#008080"&gt;2&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt;, &lt;/FONT&gt;&lt;FONT face="Courier New" size="2" color="#800080"&gt;'SU'&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;));&lt;/FONT&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Good idea. One could apply the LEFT function to the result in order to avoid discrepancies like &lt;FONT face="courier new,courier"&gt;'Renegade'&lt;/FONT&gt; vs. &lt;FONT face="courier new,courier"&gt;'&amp;nbsp;Renegade'&lt;/FONT&gt;.&lt;/P&gt;</description>
      <pubDate>Tue, 24 May 2016 09:22:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Parsing-CamelCase/m-p/272656#M54263</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2016-05-24T09:22:48Z</dc:date>
    </item>
    <item>
      <title>Re: Parsing CamelCase</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Parsing-CamelCase/m-p/272837#M54302</link>
      <description>&lt;P&gt;Thanks Jerry. This also works and is compact!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;A couple questions:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;(1) Why do you have to start at the second character position?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;(2) Does a blank argument for the charlist include all alphanumeric character? (Couldn't find this answer in the SAS Documentation of the findc function.)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you again.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 24 May 2016 18:41:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Parsing-CamelCase/m-p/272837#M54302</guid>
      <dc:creator>dhrumil_patel</dc:creator>
      <dc:date>2016-05-24T18:41:05Z</dc:date>
    </item>
    <item>
      <title>Re: Parsing CamelCase</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Parsing-CamelCase/m-p/272910#M54321</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/45524"&gt;@dhrumil_patel&lt;/a&gt; wrote:&lt;BR /&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;A couple questions:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;(1) Why do you have to start at the second character position?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;(2) Does a blank argument for the charlist include all alphanumeric character? (Couldn't find this answer in the SAS Documentation of the findc function.)&lt;/P&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;If you start&amp;nbsp;at the first character, the answer will include the Make of the vehicle.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And leaving the &amp;nbsp;charlist argument blank effectively means 'any character(s)'.&amp;nbsp; The modifiers U and&amp;nbsp;S stipulate what to search for.&amp;nbsp; The doco for the&amp;nbsp;&lt;A href="https://support.sas.com/documentation/cdl/en/lefunctionsref/67960/HTML/default/viewer.htm#n1mdh2gvd5potjn14jipysvzn4o7.htm" target="_blank"&gt;FINDC&lt;/A&gt;&amp;nbsp;&amp;nbsp;function&amp;nbsp;is quite good.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;@Oh, and use @FreelanceReinhard 's suggestion to wrap a LEFT function around the result to finish the job properly.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 24 May 2016 23:56:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Parsing-CamelCase/m-p/272910#M54321</guid>
      <dc:creator>JerryLeBreton</dc:creator>
      <dc:date>2016-05-24T23:56:50Z</dc:date>
    </item>
  </channel>
</rss>

