<?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: Remove blank from &amp;quot;strange&amp;quot; string in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Remove-blank-from-quot-strange-quot-string/m-p/377380#M90606</link>
    <description>&lt;P&gt;Your question does not make sense.&lt;/P&gt;
&lt;PRE&gt;I need to remove the last 10 blanks from string (DB_OPER):
AS IS "CON.CBILL 003D2          "  
TO BE "CON.CBILL 003D2"
. &lt;/PRE&gt;
&lt;P&gt;The variable DB_OPER is defined to have a specific length. When you assign a shorter value to it then SAS will automatically fill out the rest of the string with blanks.&lt;/P&gt;
&lt;P&gt;Why does this cause you any trouble?&lt;/P&gt;
&lt;P&gt;If want to concatenate values to form a new value then use the proper functions. &amp;nbsp;So to make 'cowboy' from 'cow' and 'boy' use the CATS() function to remove the blanks.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;length x y z $25 ;
x='cow';
y='boy';
z=cats(x,y);
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Wed, 19 Jul 2017 15:10:52 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2017-07-19T15:10:52Z</dc:date>
    <item>
      <title>Remove blank from "strange" string</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Remove-blank-from-quot-strange-quot-string/m-p/377272#M90576</link>
      <description>&lt;P&gt;hi,&lt;BR /&gt;i have a problem with some records, this is an example:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data  WORKUSI.T03_TOT_SUM2 (keep= DB_OPER  LENGTHN TIPOPER_ DB_SUB DB_CAU DB_COMP left_ )   ;
set WORKUSI.T03_TOT_SUM ;
LENGTHN = LENGTHN(DB_OPER);
DB_COMP= COMPRESS(DB_OPER)!!TIPOPER_;
DB_TRI= TRIM(DB_OPER)!!TIPOPER_;
DB_CAU = substr(db_oper,1,length(DB_OPER)-10)!!TIPOPER_; 
DB_SUB=  substr(db_oper,1,length(DB_OPER))!!TIPOPER_;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;IMG title="example.JPG" alt="example.JPG" src="https://communities.sas.com/t5/image/serverpage/image-id/10404i2157934EE3662643/image-size/original?v=1.0&amp;amp;px=-1" border="0" /&gt;&lt;/P&gt;
&lt;P&gt;DB_OPER is char 60&lt;/P&gt;
&lt;P&gt;"CON.CBILL 003D2&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; "&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;TIPOPER is char 8&lt;/P&gt;
&lt;P&gt;"M900000"&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Lengh of DB_OPER&amp;nbsp;is&amp;nbsp;25 but&amp;nbsp;the last 10 position are blank.&lt;/P&gt;
&lt;P&gt;I need to remove the last 10 blanks from&amp;nbsp;string (DB_OPER): AS IS&amp;nbsp;"CON.CBILL 003D2&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; "&amp;nbsp;&amp;nbsp;TO BE &amp;nbsp;"CON.CBILL 003D2".&amp;nbsp;&lt;/P&gt;
&lt;P&gt;My problem is have different string&amp;nbsp;and the number of blank in the end of the string are varibable: whith function&amp;nbsp; compress, trim&amp;nbsp;haven't result.&lt;/P&gt;
&lt;P&gt;Please&amp;nbsp;help.&lt;/P&gt;
&lt;P&gt;thank you very much&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 19 Jul 2017 12:23:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Remove-blank-from-quot-strange-quot-string/m-p/377272#M90576</guid>
      <dc:creator>Cello23</dc:creator>
      <dc:date>2017-07-19T12:23:08Z</dc:date>
    </item>
    <item>
      <title>Re: Remove blank from "strange" string</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Remove-blank-from-quot-strange-quot-string/m-p/377287#M90581</link>
      <description>&lt;P&gt;TRIM removes trailing blanks.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;STRIP removes both leading and trailing blanks.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;COMPRESS removes all blanks (and can be used to impact other characters, not just blanks).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But there is no function that allows the length of a variable to change from one observation to the next.&amp;nbsp; Each variable has a fixed length.&amp;nbsp; So if&amp;nbsp; you want the number of characters to change, with no trailing blanks allowed, you have to do something different when writing out the value of the variable.&lt;/P&gt;</description>
      <pubDate>Wed, 19 Jul 2017 12:40:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Remove-blank-from-quot-strange-quot-string/m-p/377287#M90581</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2017-07-19T12:40:52Z</dc:date>
    </item>
    <item>
      <title>Re: Remove blank from "strange" string</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Remove-blank-from-quot-strange-quot-string/m-p/377314#M90589</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please avoid coding in random case it makes reading the code very hard - look at other code samples here for style guide. &amp;nbsp;Also avoid using SAS function names as variable names, first it makes reading your code very hard, second it can lead to logic issues (as some functions can be on both sides of the equals).&lt;/P&gt;
&lt;P&gt;Now what is your issue exactly? &amp;nbsp;Strings are made up of boxes to the length of the string - each box can contain a character. &amp;nbsp;Hence any string with less characters in than the length of the string will have blanks at the end. &amp;nbsp;This is how they work.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you are after shortening variable lengths, then refer to this post:&lt;/P&gt;
&lt;P&gt;&lt;A href="https://communities.sas.com/t5/General-SAS-Programming/output-from-iteration/m-p/377253" target="_blank"&gt;https://communities.sas.com/t5/General-SAS-Programming/output-from-iteration/m-p/377253&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Which is exactly the same question and the same applies here.&lt;/P&gt;</description>
      <pubDate>Wed, 19 Jul 2017 13:33:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Remove-blank-from-quot-strange-quot-string/m-p/377314#M90589</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2017-07-19T13:33:10Z</dc:date>
    </item>
    <item>
      <title>Re: Remove blank from "strange" string</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Remove-blank-from-quot-strange-quot-string/m-p/377380#M90606</link>
      <description>&lt;P&gt;Your question does not make sense.&lt;/P&gt;
&lt;PRE&gt;I need to remove the last 10 blanks from string (DB_OPER):
AS IS "CON.CBILL 003D2          "  
TO BE "CON.CBILL 003D2"
. &lt;/PRE&gt;
&lt;P&gt;The variable DB_OPER is defined to have a specific length. When you assign a shorter value to it then SAS will automatically fill out the rest of the string with blanks.&lt;/P&gt;
&lt;P&gt;Why does this cause you any trouble?&lt;/P&gt;
&lt;P&gt;If want to concatenate values to form a new value then use the proper functions. &amp;nbsp;So to make 'cowboy' from 'cow' and 'boy' use the CATS() function to remove the blanks.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;length x y z $25 ;
x='cow';
y='boy';
z=cats(x,y);
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 19 Jul 2017 15:10:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Remove-blank-from-quot-strange-quot-string/m-p/377380#M90606</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2017-07-19T15:10:52Z</dc:date>
    </item>
    <item>
      <title>Re: Remove blank from "strange" string</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Remove-blank-from-quot-strange-quot-string/m-p/377457#M90639</link>
      <description>&lt;P&gt;In this case, casts&amp;nbsp;n&lt;SPAN&gt;ot work:&lt;/SPAN&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data  WORKUSI.T03_TOT_SUM2 (keep= DB_OPER  TIPOPER_ z )   ;
set WORKUSI.T03_TOT_SUM ;
z=cats(DB_OPER,TIPOPER_ );
run;&lt;BR /&gt;&lt;BR /&gt;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I don't know the reason.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;IMG title="example2.JPG" alt="example2.JPG" src="https://communities.sas.com/t5/image/serverpage/image-id/10411i31FE9FE74BECF890/image-size/original?v=1.0&amp;amp;px=-1" border="0" /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This is the db SAS:&lt;/P&gt;
&lt;P&gt;&lt;A href="https://drive.google.com/file/d/0B3qwWJU0WR1cUzJubTNlUWtGM0U/view?usp=sharing" target="_self"&gt;https://drive.google.com/file/d/0B3qwWJU0WR1cUzJubTNlUWtGM0U/view?usp=sharing&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;Thank you vary much&lt;/P&gt;
&lt;P&gt;M.&lt;/P&gt;</description>
      <pubDate>Wed, 19 Jul 2017 16:56:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Remove-blank-from-quot-strange-quot-string/m-p/377457#M90639</guid>
      <dc:creator>Cello23</dc:creator>
      <dc:date>2017-07-19T16:56:18Z</dc:date>
    </item>
    <item>
      <title>Re: Remove blank from "strange" string</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Remove-blank-from-quot-strange-quot-string/m-p/377475#M90645</link>
      <description>&lt;P&gt;Most likely, your data contains some strange characters that aren't displaying.&amp;nbsp; They're not blanks, but they look like blanks.&amp;nbsp; For example, it's possible that the value of DB_OPER contains a carriage return at the end.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;First, discover what is actually in there by printing in HEX format.&amp;nbsp; If DB_OPER is defined as $30, test with:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;put DB_OPER $hex60.;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Once the special characters are identified, COMPRESS can remove them.&amp;nbsp; But first we have to see what they are.&lt;/P&gt;</description>
      <pubDate>Wed, 19 Jul 2017 17:30:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Remove-blank-from-quot-strange-quot-string/m-p/377475#M90645</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2017-07-19T17:30:27Z</dc:date>
    </item>
    <item>
      <title>Re: Remove blank from "strange" string</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Remove-blank-from-quot-strange-quot-string/m-p/377661#M90706</link>
      <description>&lt;P&gt;THANK YOU &lt;A class="lia-link-navigation lia-page-link lia-user-name-link" id="link_8" style="color: rgb(0, 125, 195);" href="https://communities.sas.com/t5/user/viewprofilepage/user-id/4954" target="_self"&gt;&lt;SPAN class="login-bold"&gt;Astounding&lt;/SPAN&gt;&lt;/A&gt; .&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;DB_OPER is $60.&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="1"&gt;also &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="1"&gt;DB_HEX = put(DB_OPER,&lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="1"&gt;$hex120.&lt;/FONT&gt;&lt;FONT face="Courier New" size="1"&gt;);&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;is it correct ?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This is result&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="1"&gt;DB_HEX = put(DB_OPER,&lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="1"&gt;$hex120.&lt;/FONT&gt;&lt;FONT face="Courier New" size="1"&gt;);&lt;/FONT&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;FONT face="Courier New" size="1"&gt;&lt;CODE class=" language-sas"&gt;434F4E2E4342494C4C203030334432000000000000000000002020202020202020202020202020202020202020202020202020202020202020202020&lt;/CODE&gt;&lt;/FONT&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="1"&gt;&lt;SPAN&gt;Can I identify special characters?&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="1"&gt;&lt;SPAN&gt;thank's!!&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 20 Jul 2017 07:22:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Remove-blank-from-quot-strange-quot-string/m-p/377661#M90706</guid>
      <dc:creator>Cello23</dc:creator>
      <dc:date>2017-07-20T07:22:04Z</dc:date>
    </item>
    <item>
      <title>Re: Remove blank from "strange" string</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Remove-blank-from-quot-strange-quot-string/m-p/377688#M90713</link>
      <description>&lt;P&gt;Yes. &amp;nbsp;A blank is "20" in hex. You have some null characters here (hex "00"); &amp;nbsp;To get rid of them (essentially replacing them with blanks):&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;db_oper = compress(db_oper, '00'x);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Then the rest of your code should work as expected.&lt;/P&gt;</description>
      <pubDate>Thu, 20 Jul 2017 10:34:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Remove-blank-from-quot-strange-quot-string/m-p/377688#M90713</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2017-07-20T10:34:20Z</dc:date>
    </item>
    <item>
      <title>Re: Remove blank from "strange" string</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Remove-blank-from-quot-strange-quot-string/m-p/378923#M91122</link>
      <description>&lt;P&gt;&lt;img id="smileysad" class="emoticon emoticon-smileysad" src="https://communities.sas.com/i/smilies/16x16_smiley-sad.png" alt="Smiley Sad" title="Smiley Sad" /&gt; don't work ...&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data  WORKUSI.T03_TOT_SUM2 (keep= DB_OPER  TIPOPER_ DB_CAU DB_SUB )   ;
set WORKUSI.T03_TOT_SUM ;
DB_CAU = substr(db_oper,1,length(DB_OPER)-10)!!TIPOPER_; 
DB_SUB = compress(db_oper, '00'x)!!TIPOPER_;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;IMG title="example3.JPG" alt="example3.JPG" src="https://communities.sas.com/t5/image/serverpage/image-id/10503iA8F6139F50556D25/image-size/original?v=1.0&amp;amp;px=-1" border="0" /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="short_text"&gt;&lt;SPAN&gt;Do you have any advice?&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="short_text"&gt;Thnanks!!!&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 25 Jul 2017 11:01:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Remove-blank-from-quot-strange-quot-string/m-p/378923#M91122</guid>
      <dc:creator>Cello23</dc:creator>
      <dc:date>2017-07-25T11:01:42Z</dc:date>
    </item>
    <item>
      <title>Re: Remove blank from "strange" string</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Remove-blank-from-quot-strange-quot-string/m-p/378925#M91123</link>
      <description>&lt;P&gt;First, use the code I suggested to change DB_OPER. &amp;nbsp;Then use the CATS function.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;After removing the null characters, there are still trailing blanks to consider. &amp;nbsp;But CATS will remove those.&lt;/P&gt;</description>
      <pubDate>Tue, 25 Jul 2017 11:15:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Remove-blank-from-quot-strange-quot-string/m-p/378925#M91123</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2017-07-25T11:15:11Z</dc:date>
    </item>
    <item>
      <title>Re: Remove blank from "strange" string</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Remove-blank-from-quot-strange-quot-string/m-p/378944#M91136</link>
      <description>Thank you so much!!!</description>
      <pubDate>Tue, 25 Jul 2017 12:23:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Remove-blank-from-quot-strange-quot-string/m-p/378944#M91136</guid>
      <dc:creator>Cello23</dc:creator>
      <dc:date>2017-07-25T12:23:21Z</dc:date>
    </item>
  </channel>
</rss>

