<?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 find length in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-find-length/m-p/838919#M331709</link>
    <description>&lt;P&gt;Thank u so much for helping&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 17 Oct 2022 09:16:34 GMT</pubDate>
    <dc:creator>venunaidu</dc:creator>
    <dc:date>2022-10-17T09:16:34Z</dc:date>
    <item>
      <title>How to find length</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-find-length/m-p/838897#M331699</link>
      <description>&lt;P&gt;data ds;&lt;/P&gt;&lt;P&gt;infile datelines;&lt;/P&gt;&lt;P&gt;input num;&lt;/P&gt;&lt;P&gt;cards;&lt;/P&gt;&lt;P&gt;1234567891&lt;/P&gt;&lt;P&gt;12345678901&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;in above data I have observation length 10 &amp;nbsp;but when &amp;nbsp;I am use if condition not work .&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;like ex:&lt;/P&gt;&lt;P&gt;data ds2 ds3;&lt;/P&gt;&lt;P&gt;set ds;&lt;/P&gt;&lt;P&gt;if length(num) eq 10 then output ds2;&lt;/P&gt;&lt;P&gt;else output ds3;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;above data &amp;nbsp;if &amp;nbsp;condition not work anyone can explain me , above data by default length take best12.&amp;nbsp;&lt;/P&gt;&lt;P&gt;how to find exact length .&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 17 Oct 2022 05:30:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-find-length/m-p/838897#M331699</guid>
      <dc:creator>venunaidu</dc:creator>
      <dc:date>2022-10-17T05:30:24Z</dc:date>
    </item>
    <item>
      <title>Re: How to find length</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-find-length/m-p/838899#M331700</link>
      <description>&lt;P&gt;Since the num variable in the ds data set is a numeric variable, the length of a string cannot be obtained.&lt;BR /&gt;If it is treated as a character variable, the length can be obtained as follows.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data ds;
length num $20;
input num $;
cards;
1234567891
12345678901
run;

data _null_;
  set ds;
  len=length(num);
  put len=;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Or, if you want to treat them as numbers, you can convert them to charactors.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data ds;
input num;
cards;
1234567891
12345678901
run;

data _null_;
  set ds;
  len=length(strip(put(num,best12.)));
  put len=;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 17 Oct 2022 05:51:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-find-length/m-p/838899#M331700</guid>
      <dc:creator>japelin</dc:creator>
      <dc:date>2022-10-17T05:51:09Z</dc:date>
    </item>
    <item>
      <title>Re: How to find length</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-find-length/m-p/838900#M331701</link>
      <description>&lt;P&gt;Your variable NUM is of type NUMERIC.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Length() is a string function that requires variables of type CHARACTER.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you want to know for a numerical variable how many digits an integer has then below one way to get there.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
  set ds;
  l=length(put(int(num),f16. -l));
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 17 Oct 2022 05:50:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-find-length/m-p/838900#M331701</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2022-10-17T05:50:04Z</dc:date>
    </item>
    <item>
      <title>Re: How to find length</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-find-length/m-p/838919#M331709</link>
      <description>&lt;P&gt;Thank u so much for helping&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 17 Oct 2022 09:16:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-find-length/m-p/838919#M331709</guid>
      <dc:creator>venunaidu</dc:creator>
      <dc:date>2022-10-17T09:16:34Z</dc:date>
    </item>
    <item>
      <title>Re: How to find length</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-find-length/m-p/838949#M331715</link>
      <description>&lt;PRE&gt;data ds2 ds3;
set ds; 
if int(log10(num))+1 eq 10 then output ds2;
else output ds3;
run;&lt;/PRE&gt;</description>
      <pubDate>Mon, 17 Oct 2022 12:29:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-find-length/m-p/838949#M331715</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2022-10-17T12:29:42Z</dc:date>
    </item>
  </channel>
</rss>

