<?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: Calculating length of a variable in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Calculating-length-of-a-variable/m-p/588525#M14806</link>
    <description>&lt;P&gt;Fun stuff&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/290100"&gt;@zishaq&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input str $12.;
cards;
111111111111
110111111111
111111111110
011111111111
011011110110
;

data want;
set have;
first=findc(str,'1');
last=findc(str,'1','b');
want=last-first;
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Fri, 13 Sep 2019 13:49:47 GMT</pubDate>
    <dc:creator>novinosrin</dc:creator>
    <dc:date>2019-09-13T13:49:47Z</dc:date>
    <item>
      <title>Calculating length of a variable</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Calculating-length-of-a-variable/m-p/588522#M14804</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm hoping somebody can help me out with something that seems fairly simple!&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a character variable called 'Emp' which is 12 characters long and contains the numbers 1 and 0 only. For example;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;111111111111&lt;/P&gt;&lt;P&gt;110111111111&lt;/P&gt;&lt;P&gt;111111111110&lt;/P&gt;&lt;P&gt;011111111111&lt;/P&gt;&lt;P&gt;011011110110&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to work out the difference between the position of the first '1' and the last '1' for each row. The answers should be 11 (for the 1st row), 11 (for the 2nd row), 10 (for the 3rd row), 10 (for the 4th row) and 9 (for the 5th row).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can somebody help me put this in to a code without having to go through each line manually?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 13 Sep 2019 13:44:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Calculating-length-of-a-variable/m-p/588522#M14804</guid>
      <dc:creator>zishaq</dc:creator>
      <dc:date>2019-09-13T13:44:47Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating length of a variable</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Calculating-length-of-a-variable/m-p/588525#M14806</link>
      <description>&lt;P&gt;Fun stuff&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/290100"&gt;@zishaq&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input str $12.;
cards;
111111111111
110111111111
111111111110
011111111111
011011110110
;

data want;
set have;
first=findc(str,'1');
last=findc(str,'1','b');
want=last-first;
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 13 Sep 2019 13:49:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Calculating-length-of-a-variable/m-p/588525#M14806</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2019-09-13T13:49:47Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating length of a variable</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Calculating-length-of-a-variable/m-p/588526#M14807</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
    set have;
    length_of_string=length(x);
    first_one=find(x,'1');
    last_one=length_of_string-find(reverse(x),'1')+1;
    distance=last_one-first_one;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 13 Sep 2019 13:54:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Calculating-length-of-a-variable/m-p/588526#M14807</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2019-09-13T13:54:33Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating length of a variable</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Calculating-length-of-a-variable/m-p/588530#M14808</link>
      <description>Thanks a lot!</description>
      <pubDate>Fri, 13 Sep 2019 14:00:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Calculating-length-of-a-variable/m-p/588530#M14808</guid>
      <dc:creator>zishaq</dc:creator>
      <dc:date>2019-09-13T14:00:05Z</dc:date>
    </item>
  </channel>
</rss>

