<?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: First period in failure in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/First-period-in-failure/m-p/543918#M150372</link>
    <description>&lt;P&gt;Something easy like:&lt;/P&gt;
&lt;PRE&gt;data rawdata;
  input id follow1 follow2 follow3 follow4 follow5;
cards;
1 0 0 1 1 1
2 1 1 1 0 0
3 0 1 0 1 1
4 0 0 0 0 0
;
run;

data want;
  set rawdata;
  want=whichn(1,of follow:);
run;
  &lt;/PRE&gt;</description>
    <pubDate>Mon, 18 Mar 2019 09:51:45 GMT</pubDate>
    <dc:creator>RW9</dc:creator>
    <dc:date>2019-03-18T09:51:45Z</dc:date>
    <item>
      <title>First period in failure</title>
      <link>https://communities.sas.com/t5/SAS-Programming/First-period-in-failure/m-p/543911#M150370</link>
      <description>&lt;P&gt;Hello&lt;/P&gt;
&lt;P&gt;For each customer I have follow up of 5 periods.&lt;/P&gt;
&lt;P&gt;I want to create a new column with information of number of periods it took to customer to arrive failure.&lt;/P&gt;
&lt;P&gt;For example:&lt;/P&gt;
&lt;P&gt;customer1: 3&lt;/P&gt;
&lt;P&gt;customer2: 1&lt;BR /&gt;customer3: 2&lt;/P&gt;
&lt;P&gt;customer4: 0&lt;/P&gt;
&lt;P&gt;How can I calculate it please?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Data RawData;
input id Follow1  Follow2 Follow3 Follow4 Follow5;
cards;
1 0 0 1 1 1
2 1 1 1 0 0
3 0 1 0 1 1
4 0 0 0 0 0
;
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 18 Mar 2019 09:24:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/First-period-in-failure/m-p/543911#M150370</guid>
      <dc:creator>Ronein</dc:creator>
      <dc:date>2019-03-18T09:24:03Z</dc:date>
    </item>
    <item>
      <title>Re: First period in failure</title>
      <link>https://communities.sas.com/t5/SAS-Programming/First-period-in-failure/m-p/543917#M150371</link>
      <description>&lt;P&gt;Another nice case for transposing to long format:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Data RawData;
input id Follow1  Follow2 Follow3 Follow4 Follow5;
cards;
1 0 0 1 1 1
2 1 1 1 0 0
3 0 1 0 1 1
4 0 0 0 0 0
;
run;

proc transpose data=rawdata out=trans (where=(col1 ne 0));
by id;
var follow:;
run;

data want;
merge
  rawdata
  trans (in=b)
;
by id;
if first.id;
if b
then first_failure = input(substr(_name_,7,1),1.);
else first_failure = 0;
keep id follow: first_failure;
run;

proc print data=want noobs;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Result:&lt;/P&gt;
&lt;PRE&gt;                                                              first_
id    Follow1    Follow2    Follow3    Follow4    Follow5    failure

 1       0          0          1          1          1          3   
 2       1          1          1          0          0          1   
 3       0          1          0          1          1          2   
 4       0          0          0          0          0          0   
&lt;/PRE&gt;</description>
      <pubDate>Mon, 18 Mar 2019 09:49:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/First-period-in-failure/m-p/543917#M150371</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2019-03-18T09:49:35Z</dc:date>
    </item>
    <item>
      <title>Re: First period in failure</title>
      <link>https://communities.sas.com/t5/SAS-Programming/First-period-in-failure/m-p/543918#M150372</link>
      <description>&lt;P&gt;Something easy like:&lt;/P&gt;
&lt;PRE&gt;data rawdata;
  input id follow1 follow2 follow3 follow4 follow5;
cards;
1 0 0 1 1 1
2 1 1 1 0 0
3 0 1 0 1 1
4 0 0 0 0 0
;
run;

data want;
  set rawdata;
  want=whichn(1,of follow:);
run;
  &lt;/PRE&gt;</description>
      <pubDate>Mon, 18 Mar 2019 09:51:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/First-period-in-failure/m-p/543918#M150372</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2019-03-18T09:51:45Z</dc:date>
    </item>
  </channel>
</rss>

