<?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, trimn, compress problem in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/trim-trimn-compress-problem/m-p/186909#M35393</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you! In fact I used only call symputx, as I already had a lot of call symput statement I just had to add a few xs :smileygrin: &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 06 Mar 2014 11:44:51 GMT</pubDate>
    <dc:creator>gusfryk01</dc:creator>
    <dc:date>2014-03-06T11:44:51Z</dc:date>
    <item>
      <title>trim, trimn, compress problem</title>
      <link>https://communities.sas.com/t5/SAS-Programming/trim-trimn-compress-problem/m-p/186905#M35389</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt; I´m unable to remove all the blanks (especially trailing blanks) from character variables.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have the following macrovariables:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;amp;Period1&lt;/P&gt;&lt;P&gt;&amp;amp;Period2&lt;/P&gt;&lt;P&gt;&amp;amp;Period3&lt;/P&gt;&lt;P&gt;&amp;amp;Period4&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;and want another macrovariable that´s a concatenation of these. &lt;/P&gt;&lt;P&gt;So if the values of these macro variables is 1, 2, 3 and 4 respectively I want a macrovariable called &amp;amp;Period1_4 that has the value 1234, and without any blanks.&lt;/P&gt;&lt;P&gt;I´ve tried to achive that using this method&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data _NULL_;&lt;/P&gt;&lt;P&gt;period1_4=compress("&amp;amp;period1.&amp;amp;period2.&amp;amp;period3.&amp;amp;period4.", " ");&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;format period1_4 $4.;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;call symput('period1_4', period1_4);&lt;/P&gt;&lt;DIV&gt;run;&lt;/DIV&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;but I just can´t get rid of those blanks.....&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If I execute&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; data _NULL_;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; x="&amp;amp;period1_4.testing1234";&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; put x;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I get the following result: &lt;/P&gt;&lt;P&gt;1234&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; testing1234&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I´ve tried the trim and trimn functions to but nothing helps so I need some advice from you out there.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 25 Feb 2014 20:59:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/trim-trimn-compress-problem/m-p/186905#M35389</guid>
      <dc:creator>gusfryk01</dc:creator>
      <dc:date>2014-02-25T20:59:52Z</dc:date>
    </item>
    <item>
      <title>Re: trim, trimn, compress problem</title>
      <link>https://communities.sas.com/t5/SAS-Programming/trim-trimn-compress-problem/m-p/186906#M35390</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;call symputx and catt, though I think call symputx is possibly overkill &lt;img id="smileyhappy" class="emoticon emoticon-smileyhappy" src="https://communities.sas.com/i/smilies/16x16_smiley-happy.png" alt="Smiley Happy" title="Smiley Happy" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%let period1=1;&lt;/P&gt;&lt;P&gt;%let period2=2;&lt;/P&gt;&lt;P&gt;%let period3=3;&lt;/P&gt;&lt;P&gt;%let period4=4;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data _NULL_;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;period1_4=catt("&amp;amp;period1.","&amp;amp;period2.","&amp;amp;period3.","&amp;amp;period4.");&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;format period1_4 $4.;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;call symputx('period1_4', period1_4);&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%put &amp;amp;period1_4.;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 25 Feb 2014 21:05:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/trim-trimn-compress-problem/m-p/186906#M35390</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2014-02-25T21:05:58Z</dc:date>
    </item>
    <item>
      <title>Re: trim, trimn, compress problem</title>
      <link>https://communities.sas.com/t5/SAS-Programming/trim-trimn-compress-problem/m-p/186907#M35391</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Have you tried&lt;/P&gt;&lt;P&gt;x= cats("&amp;amp;period1_4","testing1234");&lt;/P&gt;&lt;P&gt;?&lt;/P&gt;&lt;P&gt;It looks like you are trying to control the actual storage length of variable period1_4 with a format. Doesn't work, format only affects the way the value is displayed.&lt;/P&gt;&lt;P&gt;To control the physical stored length of a variable use the Length statement BEFORE the first use/creation of the variable:&lt;/P&gt;&lt;P&gt;Length period1_4 $ 4.;&lt;/P&gt;&lt;P&gt;period1_4=compress("&amp;amp;period1.&amp;amp;period2.&amp;amp;period3.&amp;amp;period4.", " ");&lt;/P&gt;&lt;P&gt;Compress was returning a much longer value.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You may get the string you want into a macro variable using&lt;/P&gt;&lt;P&gt;%let period1_4 = &amp;amp;period1.&amp;amp;period2.&amp;amp;period3.&amp;amp;period4;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 25 Feb 2014 21:09:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/trim-trimn-compress-problem/m-p/186907#M35391</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2014-02-25T21:09:47Z</dc:date>
    </item>
    <item>
      <title>Re: trim, trimn, compress problem</title>
      <link>https://communities.sas.com/t5/SAS-Programming/trim-trimn-compress-problem/m-p/186908#M35392</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If you are starting with 4 macro variables, you don't need to use any DATA step tools.&amp;nbsp; This should do it:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%let period1 = &amp;amp;period1;&lt;/P&gt;&lt;P&gt;%let period2 = &amp;amp;period2;&lt;/P&gt;&lt;P&gt;%let period3 = &amp;amp;period3;&lt;/P&gt;&lt;P&gt;%let period4 = &amp;amp;period4;&lt;/P&gt;&lt;P&gt;%let period1_4 = &amp;amp;period.&amp;amp;period2.&amp;amp;period3.&amp;amp;period4.;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The %LET statement ignores leading and trailing blanks to the right of the equal sign.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Of course, you may still want to understand the tools, and why those blanks got in there in the first place.&amp;nbsp; But that's a separate question, since you're not showing the code that created the 4 variables.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 25 Feb 2014 21:15:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/trim-trimn-compress-problem/m-p/186908#M35392</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2014-02-25T21:15:55Z</dc:date>
    </item>
    <item>
      <title>Re: trim, trimn, compress problem</title>
      <link>https://communities.sas.com/t5/SAS-Programming/trim-trimn-compress-problem/m-p/186909#M35393</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you! In fact I used only call symputx, as I already had a lot of call symput statement I just had to add a few xs :smileygrin: &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 06 Mar 2014 11:44:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/trim-trimn-compress-problem/m-p/186909#M35393</guid>
      <dc:creator>gusfryk01</dc:creator>
      <dc:date>2014-03-06T11:44:51Z</dc:date>
    </item>
  </channel>
</rss>

