<?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: How to count the number of characters in a variable? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-count-the-number-of-characters-in-a-variable/m-p/711753#M219301</link>
    <description>&lt;P&gt;The LENGTH() function will tell you how many bytes until the last non-blank value.&amp;nbsp; That looks like what you want.&lt;/P&gt;
&lt;P&gt;And for single byte encoding it should work.&amp;nbsp; But if you are using a multi-byte encoding, like UTF-8, then some characters take more than one byte to be represented.&amp;nbsp; In that case use KLENGTH() function instead.&amp;nbsp; That will count characters instead of bytes.&lt;/P&gt;</description>
    <pubDate>Fri, 15 Jan 2021 19:08:15 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2021-01-15T19:08:15Z</dc:date>
    <item>
      <title>How to count the number of characters in a variable?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-count-the-number-of-characters-in-a-variable/m-p/711751#M219299</link>
      <description>&lt;P&gt;Hello,&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;I am trying to determine the level of detail in character variables by counting the number of characters in the values.&amp;nbsp;&lt;BR /&gt;As an example, variable 'comments' has values like 'very good', 'excellent', and 'poor service'. I want to generate a variable that will count all the characters in the 'comments' variable and will return something like this:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;very good - 9 characters&amp;nbsp;&lt;/P&gt;&lt;P&gt;excellent - 9 characters&amp;nbsp;&lt;/P&gt;&lt;P&gt;poor service - 12 characters.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have to do this for multiple variables, but I don't know how to approach this.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Thank you in advance!&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 15 Jan 2021 19:03:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-count-the-number-of-characters-in-a-variable/m-p/711751#M219299</guid>
      <dc:creator>epibio2021</dc:creator>
      <dc:date>2021-01-15T19:03:14Z</dc:date>
    </item>
    <item>
      <title>Re: How to count the number of characters in a variable?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-count-the-number-of-characters-in-a-variable/m-p/711753#M219301</link>
      <description>&lt;P&gt;The LENGTH() function will tell you how many bytes until the last non-blank value.&amp;nbsp; That looks like what you want.&lt;/P&gt;
&lt;P&gt;And for single byte encoding it should work.&amp;nbsp; But if you are using a multi-byte encoding, like UTF-8, then some characters take more than one byte to be represented.&amp;nbsp; In that case use KLENGTH() function instead.&amp;nbsp; That will count characters instead of bytes.&lt;/P&gt;</description>
      <pubDate>Fri, 15 Jan 2021 19:08:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-count-the-number-of-characters-in-a-variable/m-p/711753#M219301</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-01-15T19:08:15Z</dc:date>
    </item>
    <item>
      <title>Re: How to count the number of characters in a variable?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-count-the-number-of-characters-in-a-variable/m-p/711803#M219323</link>
      <description>&lt;P&gt;Some of the loose ends that you need to wrap up before programming begins ...&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You have already indicated that embedded blanks should be counted.&amp;nbsp; What about leading blanks?&amp;nbsp; Should they also be counted?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Do you have an exact count of how many variables you want to do this for?&amp;nbsp; Is it every character variable in your data set?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You will need to invent variables to hold the results, such as L1 for the length of the first variable, L2 for the length of the second variable, etc.&lt;/P&gt;</description>
      <pubDate>Fri, 15 Jan 2021 22:41:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-count-the-number-of-characters-in-a-variable/m-p/711803#M219323</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2021-01-15T22:41:57Z</dc:date>
    </item>
  </channel>
</rss>

