<?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: Difference in functionality of TRIM function and FIND function's trim option in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Difference-in-functionality-of-TRIM-function-and-FIND-function-s/m-p/217700#M53572</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The result of the TRIM function must be used immediately. As soon as you assign it to a SAS character variable, it gets padded with blanks to the fixed length of that variable.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 20 May 2015 20:23:43 GMT</pubDate>
    <dc:creator>PGStats</dc:creator>
    <dc:date>2015-05-20T20:23:43Z</dc:date>
    <item>
      <title>Difference in functionality of TRIM function and FIND function's trim option</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Difference-in-functionality-of-TRIM-function-and-FIND-function-s/m-p/217696#M53568</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN&gt;&lt;SPAN&gt;&lt;SPAN&gt;I am trying to use the find function in a case where both string parameters passed to it contain double quotes.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;/SPAN&gt; &lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;SPAN&gt;&lt;SPAN&gt;In doing this, I discovered the following problem: Passing a TRIM'ed string to the FIND function is not sufficient to make it work (the c1 variable below is wrong). However using the trim option ('t') of the FIND function will give the desired results (the c2 variable below is correct).&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;/SPAN&gt; &lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;SPAN&gt;&lt;SPAN&gt;Can someone explain to me why this is happening?&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Code:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="color: #000080; font-size: 12pt; font-family: Courier New;"&gt;&lt;STRONG style="color: #000080; font-size: 12pt; font-family: Courier New;"&gt;&lt;STRONG style="color: #000080; font-size: 12pt; font-family: Courier New;"&gt;data&lt;/STRONG&gt;&lt;/STRONG&gt;&lt;/STRONG&gt;&lt;SPAN style="color: #000000; font-size: 12pt; font-family: Courier New;"&gt; test;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;a = &lt;SPAN style="color: #800080; font-size: 12pt; font-family: Courier New;"&gt;"lalala""example""lalala"&lt;/SPAN&gt;&lt;SPAN style="font-size: 12pt; font-family: Courier New;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;b = trim(cat(&lt;SPAN style="color: #800080; font-size: 12pt; font-family: Courier New;"&gt;""""&lt;/SPAN&gt;&lt;SPAN style="font-size: 12pt; font-family: Courier New;"&gt;,&lt;/SPAN&gt;&lt;SPAN style="color: #800080; font-size: 12pt; font-family: Courier New;"&gt;"example"&lt;/SPAN&gt;&lt;SPAN style="font-size: 12pt; font-family: Courier New;"&gt;,&lt;/SPAN&gt;&lt;SPAN style="color: #800080; font-size: 12pt; font-family: Courier New;"&gt;""""&lt;/SPAN&gt;&lt;SPAN style="font-size: 12pt; font-family: Courier New;"&gt;));&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;c1= find(a,b,&lt;SPAN style="color: #800080; font-size: 12pt; font-family: Courier New;"&gt;'t'&lt;/SPAN&gt;&lt;SPAN style="font-size: 12pt; font-family: Courier New;"&gt;);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;DIV&gt;&lt;P&gt;c2 = find(a,b);&lt;/P&gt;&lt;/DIV&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;DIV&gt; &lt;/DIV&gt;&lt;P&gt;&lt;/P&gt;&lt;DIV&gt; &lt;/DIV&gt;&lt;P&gt;&lt;STRONG&gt;Result:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="color: #000080; font-size: 12pt; font-family: Courier New;"&gt;&lt;STRONG style="color: #000080; font-size: 12pt; font-family: Courier New;"&gt;&lt;STRONG style="color: #000080; font-size: 12pt; font-family: Courier New;"&gt;&lt;SPAN&gt;&lt;SPAN&gt;&lt;SPAN&gt;&lt;STRONG style="color: #000080; font-size: 12pt; font-family: Courier New;"&gt;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/STRONG&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;/SPAN&gt;a = lalala"example"lalala&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;/SPAN&gt;b = "example"&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;/SPAN&gt;c1 = 7 (this is correct)&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;/SPAN&gt;c2 = 0 (this is wrong)&lt;/P&gt;&lt;P&gt;&lt;BR /&gt; &lt;/P&gt;&lt;P&gt;&lt;STRONG style="color: #000080; font-size: 12pt; font-family: Courier New;"&gt;&lt;STRONG style="color: #000080; font-size: 12pt; font-family: Courier New;"&gt;&lt;STRONG style="color: #000080; font-size: 12pt; font-family: Courier New;"&gt;&lt;SPAN&gt;&lt;SPAN&gt;&lt;SPAN&gt;&lt;STRONG style="color: #000080; font-size: 12pt; font-family: Courier New;"&gt;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/STRONG&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 20 May 2015 18:46:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Difference-in-functionality-of-TRIM-function-and-FIND-function-s/m-p/217696#M53568</guid>
      <dc:creator>jakestiles</dc:creator>
      <dc:date>2015-05-20T18:46:27Z</dc:date>
    </item>
    <item>
      <title>Re: Difference in functionality of TRIM function and FIND function's trim option</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Difference-in-functionality-of-TRIM-function-and-FIND-function-s/m-p/217697#M53569</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The modifier 't' in the Find function trims trailing blanks from both a and b.&lt;/P&gt;&lt;P&gt;Without the modifier 't', then b is 200 characters in length and has many trailing blanks. So at no point does a match b because of the presence of the trailing blanks.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So if you try&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;c3=find(a,trim(b));&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;you will find that C3 = 7&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 20 May 2015 19:00:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Difference-in-functionality-of-TRIM-function-and-FIND-function-s/m-p/217697#M53569</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2015-05-20T19:00:02Z</dc:date>
    </item>
    <item>
      <title>Re: Difference in functionality of TRIM function and FIND function's trim option</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Difference-in-functionality-of-TRIM-function-and-FIND-function-s/m-p/217698#M53570</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;BR /&gt;Hi Paige,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for the quick response. That is indeed a way to use the TRIM function instead of the FIND fuction's trim option to get the desired result.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm still at a loss for why it is necessary to trim the variable b again since I already trim'd it as I was creating it in the third line of code. Can anyone explain that?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Jake&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 20 May 2015 19:04:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Difference-in-functionality-of-TRIM-function-and-FIND-function-s/m-p/217698#M53570</guid>
      <dc:creator>jakestiles</dc:creator>
      <dc:date>2015-05-20T19:04:49Z</dc:date>
    </item>
    <item>
      <title>Re: Difference in functionality of TRIM function and FIND function's trim option</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Difference-in-functionality-of-TRIM-function-and-FIND-function-s/m-p/217699#M53571</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;BR /&gt;The length of the variable created by CAT is 200 UNLESS previously specified. You trimmed the VALUE but placed into a 200 character length storage. Hence the trailing blanks.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Try this:&lt;/P&gt;&lt;P&gt;c3 = find(a,trim(b));&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;as well.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 20 May 2015 20:20:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Difference-in-functionality-of-TRIM-function-and-FIND-function-s/m-p/217699#M53571</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2015-05-20T20:20:28Z</dc:date>
    </item>
    <item>
      <title>Re: Difference in functionality of TRIM function and FIND function's trim option</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Difference-in-functionality-of-TRIM-function-and-FIND-function-s/m-p/217700#M53572</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The result of the TRIM function must be used immediately. As soon as you assign it to a SAS character variable, it gets padded with blanks to the fixed length of that variable.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 20 May 2015 20:23:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Difference-in-functionality-of-TRIM-function-and-FIND-function-s/m-p/217700#M53572</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2015-05-20T20:23:43Z</dc:date>
    </item>
    <item>
      <title>Re: Difference in functionality of TRIM function and FIND function's trim option</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Difference-in-functionality-of-TRIM-function-and-FIND-function-s/m-p/217701#M53573</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;SAS stores character strings as fixed length.&amp;nbsp; So B=TRIM(B) has no effect since SAS must add all of the spaces back onto the value when it writes it into the variable B.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 20 May 2015 21:01:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Difference-in-functionality-of-TRIM-function-and-FIND-function-s/m-p/217701#M53573</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2015-05-20T21:01:46Z</dc:date>
    </item>
  </channel>
</rss>

