<?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 Text length question? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Text-length-question/m-p/799588#M314432</link>
    <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;I would like to inquire about the length of the text ' EC1R0000' and 'ER3R00053', why did&amp;nbsp;the result come back showing the same?&amp;nbsp; &amp;nbsp;I expect the first one is 8 and the second one is 9.&amp;nbsp; Please help.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;ID_cat=length(ID);&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Wed, 02 Mar 2022 15:39:27 GMT</pubDate>
    <dc:creator>ybz12003</dc:creator>
    <dc:date>2022-03-02T15:39:27Z</dc:date>
    <item>
      <title>Text length question?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Text-length-question/m-p/799588#M314432</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;I would like to inquire about the length of the text ' EC1R0000' and 'ER3R00053', why did&amp;nbsp;the result come back showing the same?&amp;nbsp; &amp;nbsp;I expect the first one is 8 and the second one is 9.&amp;nbsp; Please help.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;ID_cat=length(ID);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 02 Mar 2022 15:39:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Text-length-question/m-p/799588#M314432</guid>
      <dc:creator>ybz12003</dc:creator>
      <dc:date>2022-03-02T15:39:27Z</dc:date>
    </item>
    <item>
      <title>Re: Text length question?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Text-length-question/m-p/799590#M314434</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What is the reported length? If 9 it is because the first value has a leading space, assuming you have shown the correct definition of the value.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Length function will not count trailing blanks in a value but will count leading spaces. If you don't want that behavior then use LEFT or STRIP functions inside the length call:&amp;nbsp; Length(left(somevar));&lt;/P&gt;</description>
      <pubDate>Wed, 02 Mar 2022 15:46:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Text-length-question/m-p/799590#M314434</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2022-03-02T15:46:39Z</dc:date>
    </item>
    <item>
      <title>Re: Text length question?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Text-length-question/m-p/799592#M314436</link>
      <description>&lt;P&gt;remove the leading space in the first ID and it will be 8.&lt;BR /&gt;Use left function for example (to remove leading space).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _NULL_;
ID=' EC1R0000'; ID_cat=length(ID); put ID_cat=; 
ID=' EC1R0000'; ID=left(ID); ID_cat=length(ID); put ID_cat=; 
ID='ER3R00053'; ID_cat=length(ID); put ID_cat=;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Koen&lt;/P&gt;</description>
      <pubDate>Wed, 02 Mar 2022 15:48:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Text-length-question/m-p/799592#M314436</guid>
      <dc:creator>sbxkoenk</dc:creator>
      <dc:date>2022-03-02T15:48:53Z</dc:date>
    </item>
    <item>
      <title>Re: Text length question?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Text-length-question/m-p/799593#M314437</link>
      <description>I use strip function, they still show the same result.</description>
      <pubDate>Wed, 02 Mar 2022 15:49:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Text-length-question/m-p/799593#M314437</guid>
      <dc:creator>ybz12003</dc:creator>
      <dc:date>2022-03-02T15:49:53Z</dc:date>
    </item>
    <item>
      <title>Re: Text length question?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Text-length-question/m-p/799594#M314438</link>
      <description>Even with Strip function, both results show 9.</description>
      <pubDate>Wed, 02 Mar 2022 15:52:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Text-length-question/m-p/799594#M314438</guid>
      <dc:creator>ybz12003</dc:creator>
      <dc:date>2022-03-02T15:52:01Z</dc:date>
    </item>
    <item>
      <title>Re: Text length question?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Text-length-question/m-p/799597#M314440</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/67134"&gt;@ybz12003&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;Even with Strip function, both results show 9.&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Which means that the leading character is NOT a space character but something else. Possibly ASCII 255 (null character).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Try putting that variable with a $HEX format. Below is an example with the first character an ASCII 255, which displays in hex as A0 below, 31 is a 1, 32 is 2, 33 is 3, 34 is 4 and 20 is a space character&lt;/P&gt;
&lt;PRE&gt;64   data _null_;
65     char = '&amp;nbsp;1234 ';
66     put char $hex.;
67    run;

A03132333420
&lt;/PRE&gt;
&lt;P&gt;Strip and Left remove spaces, not other non-printing characters. Might even be a tab or similar.&lt;/P&gt;</description>
      <pubDate>Wed, 02 Mar 2022 16:04:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Text-length-question/m-p/799597#M314440</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2022-03-02T16:04:59Z</dc:date>
    </item>
    <item>
      <title>Re: Text length question?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Text-length-question/m-p/799599#M314441</link>
      <description>&lt;P&gt;I use strip and left, and I reverse their order.&amp;nbsp; I still get the&lt;/P&gt;
&lt;PRE&gt;ID_length=length(strip(left(caseID)));&lt;/PRE&gt;
&lt;P&gt;same number, 9.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 02 Mar 2022 16:10:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Text-length-question/m-p/799599#M314441</guid>
      <dc:creator>ybz12003</dc:creator>
      <dc:date>2022-03-02T16:10:26Z</dc:date>
    </item>
    <item>
      <title>Re: Text length question?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Text-length-question/m-p/799607#M314447</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/67134"&gt;@ybz12003&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I use strip and left, and I reverse their order.&amp;nbsp; I still get the&lt;/P&gt;
&lt;PRE&gt;ID_length=length(strip(left(caseID)));&lt;/PRE&gt;
&lt;P&gt;same number, 9.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;PUT the value with HEX. You have something besides a space character.&lt;/P&gt;</description>
      <pubDate>Wed, 02 Mar 2022 16:37:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Text-length-question/m-p/799607#M314447</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2022-03-02T16:37:06Z</dc:date>
    </item>
    <item>
      <title>Re: Text length question?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Text-length-question/m-p/799613#M314449</link>
      <description>&lt;P&gt;I agree with&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13884"&gt;@ballardw&lt;/a&gt;&amp;nbsp;:&amp;nbsp;&lt;SPAN&gt;PUT the value with HEX. You have something besides a space character.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can also check if you have non-printable characters with the NOTPRINT function.&lt;/P&gt;
&lt;TABLE class="xisDoc-generatedCategoryTable"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD&gt;&lt;A href="http://127.0.0.1:54679/help/lefunctionsref.hlp/n15y8fg2brvp7in1d8ozx55y4q6z.htm" target="_blank"&gt;&lt;FONT&gt;NOTPRINT&lt;/FONT&gt; Function&lt;/A&gt;&lt;/TD&gt;
&lt;TD&gt;Searches a character string for a nonprintable character, and returns the first position at which that character is found.&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can also compress with the 's' modifier:&lt;/P&gt;
&lt;P&gt;compress function with 's' modifier.&lt;/P&gt;
&lt;DIV class="xisDoc-syntax"&gt;
&lt;DIV class="xisDoc-syntaxDescription"&gt;
&lt;DIV class="xisDoc-optionalArgGroup"&gt;
&lt;DIV id="p0t37skg8o4cfgn166syt5boeofr" class="xisDoc-argDescriptionPair"&gt;
&lt;DIV class="xisDoc-argumentDescription"&gt;
&lt;SECTION class="xisDoc-tableWrap"&gt;
&lt;TABLE class="xisDoc-listValueDescription"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD class="xisDoc-value"&gt;s or S&lt;/TD&gt;
&lt;TD class="xisDoc-valueDescription"&gt;adds space characters (blank, horizontal tab, vertical tab, carriage return, line feed, form feed, and NBSP ('A0'x, or 160 decimal ASCII) to the list of characters.&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;/SECTION&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Cheers,&lt;/P&gt;
&lt;P&gt;Koen&lt;/P&gt;</description>
      <pubDate>Wed, 02 Mar 2022 16:58:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Text-length-question/m-p/799613#M314449</guid>
      <dc:creator>sbxkoenk</dc:creator>
      <dc:date>2022-03-02T16:58:46Z</dc:date>
    </item>
    <item>
      <title>Re: Text length question?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Text-length-question/m-p/799918#M314592</link>
      <description>I got two different results with the same IDs 'EC1R00002' by running two different codes.  &lt;BR /&gt;What are they meaning?  &lt;BR /&gt;The first one showed "EC1R00002" with HEX value, "454331523030303032".&lt;BR /&gt;The second one showed "EC1R0000" with HEX value, "094543315230303030".&lt;BR /&gt;</description>
      <pubDate>Thu, 03 Mar 2022 17:11:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Text-length-question/m-p/799918#M314592</guid>
      <dc:creator>ybz12003</dc:creator>
      <dc:date>2022-03-03T17:11:14Z</dc:date>
    </item>
    <item>
      <title>Re: Text length question?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Text-length-question/m-p/799936#M314603</link>
      <description>&lt;P&gt;So your second string has a TAB character in the front.&amp;nbsp; To remove the tabs use COMPRESS() function. To convert to space use the TRANSLATE() function.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;compress(ID,'09'x)
translate(ID,' ','09'x)&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;You might want to investigate how you got the TAB character into your variable.&amp;nbsp; Note that the SAS editor in SAS/Studio has options to replace tabs with spaces when editing your program files.&amp;nbsp; You should enable this so that your program files do not accidentally get populated with tab characters.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Screenshot 2022-03-03 135528.jpg" style="width: 936px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/69117i5347F775A91A5958/image-size/large?v=v2&amp;amp;px=999" role="button" title="Screenshot 2022-03-03 135528.jpg" alt="Screenshot 2022-03-03 135528.jpg" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 03 Mar 2022 19:05:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Text-length-question/m-p/799936#M314603</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-03-03T19:05:56Z</dc:date>
    </item>
    <item>
      <title>Re: Text length question?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Text-length-question/m-p/799955#M314605</link>
      <description>I will create another question in the community.</description>
      <pubDate>Thu, 03 Mar 2022 20:34:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Text-length-question/m-p/799955#M314605</guid>
      <dc:creator>ybz12003</dc:creator>
      <dc:date>2022-03-03T20:34:17Z</dc:date>
    </item>
  </channel>
</rss>

