<?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 at then end in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Remove-blank-at-then-end/m-p/414818#M101670</link>
    <description>&lt;P&gt;Maybe you have some special blank at the end of variable.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;want=prxchange('s/\s+$//',-1,name);&lt;/P&gt;</description>
    <pubDate>Mon, 20 Nov 2017 12:55:10 GMT</pubDate>
    <dc:creator>Ksharp</dc:creator>
    <dc:date>2017-11-20T12:55:10Z</dc:date>
    <item>
      <title>Remove blank at then end</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Remove-blank-at-then-end/m-p/414738#M101634</link>
      <description>&lt;P&gt;Hi Everyone,&lt;/P&gt;
&lt;P&gt;I try both Compress and strip and still fail to remove a blank at the end of a string.&lt;/P&gt;
&lt;P&gt;That's weird since compress should remove them all.&lt;/P&gt;
&lt;P&gt;The 2nd Timothy as a space at the end.&lt;/P&gt;
&lt;P&gt;Can anyone have a look at my problem?&lt;/P&gt;
&lt;P&gt;Thank you.&lt;/P&gt;
&lt;P&gt;HC&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input name $20.;
datalines;
Od, Timothy
Od, Timothy  &amp;nbsp;
;run;

data want; set have;
new=compress(name);
new1=strip(name);
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 20 Nov 2017 02:47:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Remove-blank-at-then-end/m-p/414738#M101634</guid>
      <dc:creator>hhchenfx</dc:creator>
      <dc:date>2017-11-20T02:47:39Z</dc:date>
    </item>
    <item>
      <title>Re: Remove blank at then end</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Remove-blank-at-then-end/m-p/414739#M101635</link>
      <description>&lt;P&gt;The functions really work.&amp;nbsp; However, they require defining a new variable, with a length for the new variable.&amp;nbsp; When COMPRESS ceates a new variable, it assigns the variable a length of $200 (going by memory here).&amp;nbsp; When STRIP defines a new variable, it assigns the variable the same length as the old variable (going by what makes sense here).&amp;nbsp; So by storing the value returned by the function(s), the software has to add characters back on.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Each variable has only one length.&amp;nbsp; You could code something like this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data want;&lt;/P&gt;
&lt;P&gt;length name $ 19;&lt;/P&gt;
&lt;P&gt;set have;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;That reduces the length of NAME from $20 to $19.&amp;nbsp; But that affects all observations, and may truncate a nonblank from the end of NAME.&lt;/P&gt;</description>
      <pubDate>Mon, 20 Nov 2017 02:50:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Remove-blank-at-then-end/m-p/414739#M101635</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2017-11-20T02:50:10Z</dc:date>
    </item>
    <item>
      <title>Re: Remove blank at then end</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Remove-blank-at-then-end/m-p/414740#M101636</link>
      <description>&lt;P&gt;I have long list of name with variable length so I can't just "cut" the length.&lt;/P&gt;
&lt;P&gt;Thus the blank at the end cause me trouble&lt;/P&gt;
&lt;P&gt;If I understand what you meant, this code below still not work.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
data have;
input name $40.;
datalines;
Od, Timothy
Od, Timothy&amp;nbsp; 

;run;

data want; set have;
length new $ 200;
new=compress(name);
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 20 Nov 2017 03:00:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Remove-blank-at-then-end/m-p/414740#M101636</guid>
      <dc:creator>hhchenfx</dc:creator>
      <dc:date>2017-11-20T03:00:57Z</dc:date>
    </item>
    <item>
      <title>Re: Remove blank at then end</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Remove-blank-at-then-end/m-p/414741#M101637</link>
      <description>&lt;P&gt;Every variable is defined with one, and only one, length.&amp;nbsp; If you run a PROC CONTENTS, you can see that length.&amp;nbsp; You might be able to change the length, but there is still only one length allowed for a variable.&amp;nbsp; The length does not change from one observation to the next.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What do you want to do with the variable, where the trailing blank gets in the way?&lt;/P&gt;</description>
      <pubDate>Mon, 20 Nov 2017 03:08:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Remove-blank-at-then-end/m-p/414741#M101637</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2017-11-20T03:08:17Z</dc:date>
    </item>
    <item>
      <title>Re: Remove blank at then end</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Remove-blank-at-then-end/m-p/414743#M101638</link>
      <description>&lt;P&gt;What I meant is the list of name could be&lt;/P&gt;
&lt;P&gt;steve, Isber&lt;/P&gt;
&lt;P&gt;Kelly, Chen&lt;/P&gt;
&lt;P&gt;Jobby, Timothy&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So the length of the string is not the same from row to row.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Therefore, the length of name variable is set at $200.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So if the space appear on "&lt;SPAN&gt;steve, Isber ", changing length down to $199 will not work.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;This space at the end is so random, I don't know where are they so basically, cutting the length might cut the character.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 20 Nov 2017 03:16:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Remove-blank-at-then-end/m-p/414743#M101638</guid>
      <dc:creator>hhchenfx</dc:creator>
      <dc:date>2017-11-20T03:16:10Z</dc:date>
    </item>
    <item>
      <title>Re: Remove blank at then end</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Remove-blank-at-then-end/m-p/414744#M101639</link>
      <description>&lt;P&gt;If the length is $200, that is the number of characters used on EVERY observation.&amp;nbsp; You do not have a single blank at the end of "steve, Isber".&amp;nbsp; Instead, you have 188 blanks.&amp;nbsp; It is not random, it is that EVERY observation is using 200 characters.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you spell out some details about what you are trying to accomplish, there may be a way for the program to use 12 characters instead of 13 or 200 characters.&amp;nbsp; You you will need to show what you are trying to accomplish.&amp;nbsp; For my part, I won't be able to add more for about another 8 hours.&lt;/P&gt;</description>
      <pubDate>Mon, 20 Nov 2017 03:20:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Remove-blank-at-then-end/m-p/414744#M101639</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2017-11-20T03:20:43Z</dc:date>
    </item>
    <item>
      <title>Re: Remove blank at then end</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Remove-blank-at-then-end/m-p/414745#M101640</link>
      <description>&lt;P&gt;So I make the length of exact 19 as the longest string and I have no way to remove the space after the Timothy in this below data.&lt;/P&gt;
&lt;P&gt;in the cut1 with format cut1 $18., stevenson, Isberger loss the last "r"&lt;/P&gt;
&lt;P&gt;I try it all.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
data have;
input name $19.;
datalines;
Od, Timothy&amp;nbsp; 
stevenson, Isberger
Swan, Ng  

;run;

proc contents data=have; run;

data want; set have;
new="@"||compress(name," " )||"@";
new1="@"||strip(name)||"@";
new2="@"||trim(name)||"@";

format cut1 $18.;    
cut1=name;
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 20 Nov 2017 03:34:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Remove-blank-at-then-end/m-p/414745#M101640</guid>
      <dc:creator>hhchenfx</dc:creator>
      <dc:date>2017-11-20T03:34:15Z</dc:date>
    </item>
    <item>
      <title>Re: Remove blank at then end</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Remove-blank-at-then-end/m-p/414746#M101641</link>
      <description>&lt;P&gt;What issue is this causing?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;SAS creates variables with a fixed length and pads the remaining with spaces. There is no way to change that.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So you need to work around it, and how you do that depends on the issue you're facing.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 20 Nov 2017 03:42:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Remove-blank-at-then-end/m-p/414746#M101641</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-11-20T03:42:06Z</dc:date>
    </item>
    <item>
      <title>Re: Remove blank at then end</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Remove-blank-at-then-end/m-p/414751#M101643</link>
      <description>&lt;P&gt;The problem will be when I merge 1 file have the name of "od, timothy " and other has "od, timothy".&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I try to remove all space but it doesn't work and therefore the merge failed.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Look like in this above file, the space is a "character", not something SAS auto filled blank.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you go to SAS file and highlight that cell, you will see the "blue" cover 01 space after "timothy", which show the space.&lt;/P&gt;
&lt;P&gt;In other row, if you highlight the celll, the "blue" cover only character.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;HC&lt;/P&gt;</description>
      <pubDate>Mon, 20 Nov 2017 04:33:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Remove-blank-at-then-end/m-p/414751#M101643</guid>
      <dc:creator>hhchenfx</dc:creator>
      <dc:date>2017-11-20T04:33:43Z</dc:date>
    </item>
    <item>
      <title>Re: Remove blank at then end</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Remove-blank-at-then-end/m-p/414759#M101648</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/49486"&gt;@hhchenfx&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;The problem will be when I merge 1 file have the name of "od, timothy " and other has "od, timothy".&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I try to remove all space but it doesn't work and therefore the merge failed.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Look like in this above file, the space is a "character", not something SAS auto filled blank.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you go to SAS file and highlight that cell, you will see the "blue" cover 01 space after "timothy", which show the space.&lt;/P&gt;
&lt;P&gt;In other row, if you highlight the celll, the "blue" cover only character.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;HC&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Did you actually try to merge those two values?&amp;nbsp; SAS knows how to deal with spaces appended to the end of the variables. So in SAS if you compare 'TIM' to 'TIM&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ' they will match.&amp;nbsp;If your values are NOT matching then you do NOT have a space after the 'y' in one of the variables. Instead you have some other character code that does not display any "ink" on the page.&lt;/P&gt;
&lt;P&gt;Look at the hex codes for the character(s) that you are having trouble with.&amp;nbsp; &amp;nbsp;You can use the $HEX format to display the codes as hexadecimal values.&amp;nbsp; Some common codes that you could have might be a tab '09'x, carriage return '0d'x, what Microsoft calls a non-breaking space 'A0'x, a null character '00'x.&lt;/P&gt;
&lt;P&gt;Once you find out what character it is you can use the COMPRESS() function to remove it. Or use the TRANSLATE() or TRANWRD() functions to replace it with something else.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;name = compress(name,'00090A0DA0'x);
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 20 Nov 2017 06:42:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Remove-blank-at-then-end/m-p/414759#M101648</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2017-11-20T06:42:14Z</dc:date>
    </item>
    <item>
      <title>Re: Remove blank at then end</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Remove-blank-at-then-end/m-p/414770#M101655</link>
      <description>&lt;P&gt;If you have a character variable with questionable content, do this:&lt;/P&gt;
&lt;P&gt;- define a new variable with double the length&lt;/P&gt;
&lt;P&gt;- use newvar = put(oldvar,$hexN.); where N = length of new variable.&lt;/P&gt;
&lt;P&gt;Now you can inspect the hex codes for "funny" characters which you then can filter using &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt;'s example.&lt;/P&gt;</description>
      <pubDate>Mon, 20 Nov 2017 08:02:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Remove-blank-at-then-end/m-p/414770#M101655</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2017-11-20T08:02:56Z</dc:date>
    </item>
    <item>
      <title>Re: Remove blank at then end</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Remove-blank-at-then-end/m-p/414818#M101670</link>
      <description>&lt;P&gt;Maybe you have some special blank at the end of variable.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;want=prxchange('s/\s+$//',-1,name);&lt;/P&gt;</description>
      <pubDate>Mon, 20 Nov 2017 12:55:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Remove-blank-at-then-end/m-p/414818#M101670</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2017-11-20T12:55:10Z</dc:date>
    </item>
    <item>
      <title>Re: Remove blank at then end</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Remove-blank-at-then-end/m-p/415328#M101836</link>
      <description>&lt;P&gt;Thank you for your help.&lt;/P&gt;
&lt;P&gt;I try to upload the SAS datafile here so you can see but there is error with the upload.&lt;/P&gt;
&lt;P&gt;I will comeback to this issue later but I really appreciate your help.&lt;/P&gt;
&lt;P&gt;HC&lt;/P&gt;</description>
      <pubDate>Tue, 21 Nov 2017 22:21:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Remove-blank-at-then-end/m-p/415328#M101836</guid>
      <dc:creator>hhchenfx</dc:creator>
      <dc:date>2017-11-21T22:21:12Z</dc:date>
    </item>
  </channel>
</rss>

