<?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: Using a length statement in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Using-a-length-statement/m-p/625657#M184422</link>
    <description>A length STATEMENT sets the maximum possible length for a character variable. The length FUNCTION returns the number of characters in a variable. &lt;BR /&gt;&lt;BR /&gt;You want the length function, length().&lt;BR /&gt;&lt;BR /&gt;data want;&lt;BR /&gt;set have;&lt;BR /&gt;length_ID = length(ID_Setting);&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;*see the different values;&lt;BR /&gt;proc freq data=want;&lt;BR /&gt;table length_id;&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;*find anything not 8. &lt;BR /&gt;data not8;&lt;BR /&gt;set want;&lt;BR /&gt;where length_id ne 8;&lt;BR /&gt;run;</description>
    <pubDate>Tue, 18 Feb 2020 18:42:07 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2020-02-18T18:42:07Z</dc:date>
    <item>
      <title>Using a length statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-a-length-statement/m-p/625654#M184419</link>
      <description>&lt;P&gt;I am trying to check the length of a certain character variable. I have a variable id_Settings which all values should have a length of 8 e.g. CA455006. How do i use the length statement to check if all my observations in the ID_settings have the required length ?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Basically, how do I use length statement to check the length of variable ID_setting?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have sample data but the original data has over 2 million encounters.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data check;&lt;BR /&gt;input Name $ 1-5 ID_setting $ 7-15;&lt;BR /&gt;datalines;&lt;BR /&gt;Dog&amp;nbsp; &amp;nbsp;DO123232&lt;BR /&gt;Cat&amp;nbsp; &amp;nbsp;CA345566&lt;BR /&gt;Mouse&amp;nbsp;MO987973&lt;BR /&gt;Dog&amp;nbsp; &amp;nbsp;DO468579&lt;BR /&gt;Owl&amp;nbsp; &amp;nbsp;OW576864&lt;BR /&gt;Cat&amp;nbsp; &amp;nbsp;CA089854&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;</description>
      <pubDate>Tue, 18 Feb 2020 18:35:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-a-length-statement/m-p/625654#M184419</guid>
      <dc:creator>CathyVI</dc:creator>
      <dc:date>2020-02-18T18:35:51Z</dc:date>
    </item>
    <item>
      <title>Re: Using a length statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-a-length-statement/m-p/625655#M184420</link>
      <description>&lt;P&gt;I think you don't mean the length of the character variable, I think you mean the length of the text string in each observation. These are not the same.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In that case, you use the LENGTH function.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data check;
input Name $ 1-5 ID_setting $ 7-15;
l=length(id_setting);
datalines;
Dog   DO123232
Cat   CA345566
Mouse MO987973
Dog   DO468579
Owl   OW576864
Cat   CA089854
;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 18 Feb 2020 18:39:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-a-length-statement/m-p/625655#M184420</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2020-02-18T18:39:10Z</dc:date>
    </item>
    <item>
      <title>Re: Using a length statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-a-length-statement/m-p/625657#M184422</link>
      <description>A length STATEMENT sets the maximum possible length for a character variable. The length FUNCTION returns the number of characters in a variable. &lt;BR /&gt;&lt;BR /&gt;You want the length function, length().&lt;BR /&gt;&lt;BR /&gt;data want;&lt;BR /&gt;set have;&lt;BR /&gt;length_ID = length(ID_Setting);&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;*see the different values;&lt;BR /&gt;proc freq data=want;&lt;BR /&gt;table length_id;&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;*find anything not 8. &lt;BR /&gt;data not8;&lt;BR /&gt;set want;&lt;BR /&gt;where length_id ne 8;&lt;BR /&gt;run;</description>
      <pubDate>Tue, 18 Feb 2020 18:42:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-a-length-statement/m-p/625657#M184422</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2020-02-18T18:42:07Z</dc:date>
    </item>
    <item>
      <title>Re: Using a length statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-a-length-statement/m-p/625667#M184430</link>
      <description>&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/10892"&gt;@PaigeMiller&lt;/a&gt;, Yes, you are right i mean the length of the text string in each observation. Thank you.</description>
      <pubDate>Tue, 18 Feb 2020 19:06:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-a-length-statement/m-p/625667#M184430</guid>
      <dc:creator>CathyVI</dc:creator>
      <dc:date>2020-02-18T19:06:10Z</dc:date>
    </item>
    <item>
      <title>Re: Using a length statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-a-length-statement/m-p/625670#M184433</link>
      <description>&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza&lt;/a&gt;: Thank you! This works.</description>
      <pubDate>Tue, 18 Feb 2020 19:07:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-a-length-statement/m-p/625670#M184433</guid>
      <dc:creator>CathyVI</dc:creator>
      <dc:date>2020-02-18T19:07:31Z</dc:date>
    </item>
    <item>
      <title>Re: Using a length statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-a-length-statement/m-p/625702#M184453</link>
      <description>&lt;P&gt;Actually, you might prefer function &lt;FONT face="courier new,courier"&gt;lengthn&lt;/FONT&gt;()&amp;nbsp; since function &lt;FONT face="courier new,courier"&gt;length&lt;/FONT&gt;()&amp;nbsp; will not let you know if you have empty strings.&lt;/P&gt;</description>
      <pubDate>Tue, 18 Feb 2020 20:36:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-a-length-statement/m-p/625702#M184453</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2020-02-18T20:36:34Z</dc:date>
    </item>
  </channel>
</rss>

