<?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: Trim and left together in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Trim-and-left-together/m-p/228398#M41262</link>
    <description>Thanks RW9 and Chrish..Actually i was tring to just checking the result..It was fine too.&lt;BR /&gt;I used like&lt;BR /&gt;Y='$'||trim(left(x))||'$';--&amp;gt;$ab_cd$&lt;BR /&gt;Z='$'||left(trim(x))||'$';--&amp;gt;$ab_cd_$&lt;BR /&gt;&lt;BR /&gt;These statement ware giving same out put for y and z for one of my friend.that was $ab_cd$.So I am not sure why there are diffetence in output.</description>
    <pubDate>Mon, 05 Oct 2015 10:49:26 GMT</pubDate>
    <dc:creator>Devi</dc:creator>
    <dc:date>2015-10-05T10:49:26Z</dc:date>
    <item>
      <title>Trim and left together</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Trim-and-left-together/m-p/228388#M41256</link>
      <description>Hi all,&lt;BR /&gt;&lt;BR /&gt;Lets x="_ _ab_cd_ _";&lt;BR /&gt;(Assuming _ as a blank )&lt;BR /&gt;&lt;BR /&gt;y=trim(left(x));&lt;BR /&gt;z=left(trim(x));&lt;BR /&gt;&lt;BR /&gt;Ideally y and z should not be same.&lt;BR /&gt;But while showing outputs of y and z some times its showing the expected (y having no leading and trailing blanks and z having two trailing blanks) and some times not .&lt;BR /&gt;&lt;BR /&gt;What is the cause?&lt;BR /&gt;&lt;BR /&gt;Please suggest.&lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;Devi</description>
      <pubDate>Mon, 05 Oct 2015 08:51:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Trim-and-left-together/m-p/228388#M41256</guid>
      <dc:creator>Devi</dc:creator>
      <dc:date>2015-10-05T08:51:06Z</dc:date>
    </item>
    <item>
      <title>Re: Trim and left together</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Trim-and-left-together/m-p/228393#M41259</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please clarify what is not expected, provide some example strings in the form of a datastep and where they do not appear as you expect. &amp;nbsp;The help on each of these functions is quite clear:&lt;/P&gt;
&lt;P&gt;&lt;A href="http://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a000212224.htm" target="_blank"&gt;http://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a000212224.htm&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a000212226.htm" target="_blank"&gt;https://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a000212226.htm&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And I do not see why you would use the two functions together, unless in concatentaion. &amp;nbsp;Why not just use strip()?&lt;/P&gt;</description>
      <pubDate>Mon, 05 Oct 2015 09:31:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Trim-and-left-together/m-p/228393#M41259</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2015-10-05T09:31:22Z</dc:date>
    </item>
    <item>
      <title>Re: Trim and left together</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Trim-and-left-together/m-p/228395#M41261</link>
      <description>&lt;P&gt;1- strip() replaces these 2&lt;/P&gt;&lt;P&gt;2- It depends on the length of your variable. You'll have trailing spaces if your variable is longer than the text.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 05 Oct 2015 09:42:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Trim-and-left-together/m-p/228395#M41261</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2015-10-05T09:42:32Z</dc:date>
    </item>
    <item>
      <title>Re: Trim and left together</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Trim-and-left-together/m-p/228398#M41262</link>
      <description>Thanks RW9 and Chrish..Actually i was tring to just checking the result..It was fine too.&lt;BR /&gt;I used like&lt;BR /&gt;Y='$'||trim(left(x))||'$';--&amp;gt;$ab_cd$&lt;BR /&gt;Z='$'||left(trim(x))||'$';--&amp;gt;$ab_cd_$&lt;BR /&gt;&lt;BR /&gt;These statement ware giving same out put for y and z for one of my friend.that was $ab_cd$.So I am not sure why there are diffetence in output.</description>
      <pubDate>Mon, 05 Oct 2015 10:49:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Trim-and-left-together/m-p/228398#M41262</guid>
      <dc:creator>Devi</dc:creator>
      <dc:date>2015-10-05T10:49:26Z</dc:date>
    </item>
    <item>
      <title>Re: Trim and left together</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Trim-and-left-together/m-p/228400#M41263</link>
      <description>&lt;P&gt;Well, cant really tell from that. &amp;nbsp;I ran these two and the output was the same $ab_cd$. &amp;nbsp;Were you using different operating systems, versions of SAS, was it the same data, same options etc. &amp;nbsp;Could be any number of things. &amp;nbsp;For the code though, I would recommend using strip() as its simpler, and avoids reading the code differently. &amp;nbsp;However, an even more simpler form would be cats():&lt;/P&gt;
&lt;PRE&gt;data temp;
  x="ab_cd ";
  y="$"||trim(left(x))||"$";
  z="$"||left(trim(x))||"$";
  v="$"||strip(x)||"$";
  w=cats("$",x,"$");
run;&lt;/PRE&gt;</description>
      <pubDate>Mon, 05 Oct 2015 10:58:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Trim-and-left-together/m-p/228400#M41263</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2015-10-05T10:58:24Z</dc:date>
    </item>
    <item>
      <title>Re: Trim and left together</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Trim-and-left-together/m-p/228410#M41266</link>
      <description>You need to be specific about "the output". Sometimes SAS will strip blanks when it displays a value. You might consider using 'a0'x the so call hard space. Remember anytime you are looking a a value some kind of formatting has been done. To "see" the actual stored value use $HEX format.</description>
      <pubDate>Mon, 05 Oct 2015 13:00:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Trim-and-left-together/m-p/228410#M41266</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2015-10-05T13:00:39Z</dc:date>
    </item>
    <item>
      <title>Re: Trim and left together</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Trim-and-left-together/m-p/228417#M41269</link>
      <description>&lt;P&gt;You should expect different results.&amp;nbsp; The correct version is trim(left(value)).&amp;nbsp; Consider what happens if&amp;nbsp;you try left(trim(value)).&amp;nbsp; First, the TRIM function removes trailing blanks.&amp;nbsp; Then the LEFT function takes the leading blanks and puts them at the end of the string.&amp;nbsp; Better yet, take a look at the STRIP function that removes both leading and trailing blanks.&lt;/P&gt;</description>
      <pubDate>Mon, 05 Oct 2015 13:25:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Trim-and-left-together/m-p/228417#M41269</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2015-10-05T13:25:44Z</dc:date>
    </item>
    <item>
      <title>Re: Trim and left together</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Trim-and-left-together/m-p/228493#M41277</link>
      <description>&lt;P&gt;thanks all.&lt;BR /&gt;Actually I got the reason.&lt;BR /&gt;if we store the results in a variable a and apply any appending special character causing the same output.&lt;BR /&gt;If we assign the values to a variable results to write in data set and filling back the length by 8 characters hence same output.&lt;BR /&gt;And if apply appending a special character before storing to any variable (writing back to data set) results the different out put.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For above explanation,&lt;/P&gt;&lt;P&gt;data temp;&lt;BR /&gt;x="ab_cd ";&lt;BR /&gt;y="$"||trim(left(x))||"$";&lt;BR /&gt;z="$"||left(trim(x))||"$";&lt;BR /&gt;v="$"||strip(x)||"$";&lt;BR /&gt;w=cats("$",x,"$");&lt;BR /&gt;put y=;&lt;BR /&gt;put z=;&lt;BR /&gt;put v;&lt;BR /&gt;put w;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;y=$ab_cd$&lt;BR /&gt;z=$ab_cd $&lt;BR /&gt;$ab_cd$&lt;BR /&gt;$ab_cd$&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Devi...&lt;/P&gt;</description>
      <pubDate>Mon, 05 Oct 2015 18:52:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Trim-and-left-together/m-p/228493#M41277</guid>
      <dc:creator>Devi</dc:creator>
      <dc:date>2015-10-05T18:52:25Z</dc:date>
    </item>
    <item>
      <title>Re: Trim and left together</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Trim-and-left-together/m-p/228503#M41281</link>
      <description>&lt;P&gt;Do you see that your original question does not represent what you are actually doing?&lt;/P&gt;</description>
      <pubDate>Mon, 05 Oct 2015 19:27:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Trim-and-left-together/m-p/228503#M41281</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2015-10-05T19:27:34Z</dc:date>
    </item>
    <item>
      <title>Re: Trim and left together</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Trim-and-left-together/m-p/228515#M41283</link>
      <description>&lt;P&gt;Hi. &amp;nbsp;Be careful with character variable lengths.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The results of using character functions all have default lengths.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If you run PROC CONTENTS on data set TEMP, you'll see that the variable W created with the CATS has a length of 200 and that none of the other functions (TRIM or STRIP) change the length of the resulting variables V, Y, and Z. &amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The lengths will still be the length of any variables involved in the concatenation plus the lengths of any character constants. &amp;nbsp;In this example that's 8, not because that's the default lenght of a character variabe, but because it's 6 (length of X) plus 2 (those two $);&lt;/P&gt;</description>
      <pubDate>Mon, 05 Oct 2015 20:18:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Trim-and-left-together/m-p/228515#M41283</guid>
      <dc:creator>MikeZdeb</dc:creator>
      <dc:date>2015-10-05T20:18:54Z</dc:date>
    </item>
    <item>
      <title>Re: Trim and left together</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Trim-and-left-together/m-p/228585#M41297</link>
      <description>Hi sorry i put the another code to reference my explanation.&lt;BR /&gt;Here is it.&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Tue, 06 Oct 2015 09:03:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Trim-and-left-together/m-p/228585#M41297</guid>
      <dc:creator>Devi</dc:creator>
      <dc:date>2015-10-06T09:03:03Z</dc:date>
    </item>
    <item>
      <title>Re: Trim and left together</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Trim-and-left-together/m-p/228586#M41298</link>
      <description>73 data temp;&lt;BR /&gt;74 x=" ab cd ";&lt;BR /&gt;75 y=left(trim(x));&lt;BR /&gt;76 z=trim(left(x));&lt;BR /&gt;77 y1='$'||left(trim(x))||'$';&lt;BR /&gt;78 z1='$'||trim(left(x))||'$';&lt;BR /&gt;79 y2='$'||y||'$';&lt;BR /&gt;80 z2='$'||z||'$';&lt;BR /&gt;81&lt;BR /&gt;82 put y1=;&lt;BR /&gt;83 put z1=;&lt;BR /&gt;84 put y2=;&lt;BR /&gt;85 put z2=;&lt;BR /&gt;86&lt;BR /&gt;87 run;&lt;BR /&gt;&lt;BR /&gt;y1=$ab cd $&lt;BR /&gt;z1=$ab cd$&lt;BR /&gt;y2=$ab cd $&lt;BR /&gt;z2=$ab cd $&lt;BR /&gt;</description>
      <pubDate>Tue, 06 Oct 2015 09:03:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Trim-and-left-together/m-p/228586#M41298</guid>
      <dc:creator>Devi</dc:creator>
      <dc:date>2015-10-06T09:03:13Z</dc:date>
    </item>
    <item>
      <title>Re: Trim and left together</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Trim-and-left-together/m-p/228587#M41299</link>
      <description>Sorry I put the wrong code above to explanation of my comments.&lt;BR /&gt;Below is it.&lt;BR /&gt;See below&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Tue, 06 Oct 2015 09:13:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Trim-and-left-together/m-p/228587#M41299</guid>
      <dc:creator>Devi</dc:creator>
      <dc:date>2015-10-06T09:13:13Z</dc:date>
    </item>
  </channel>
</rss>

