<?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: ifn susbtrn for multiple lengths in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/ifn-susbtrn-for-multiple-lengths/m-p/498073#M72490</link>
    <description>&lt;P&gt;Thank you for sharing the link. If I understand correctly, they did not use the else statement with "ifn" so I am not sure it is applicable here. Maybe one of the advisors can help (@RW9)&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sat, 22 Sep 2018 13:28:57 GMT</pubDate>
    <dc:creator>lillymaginta</dc:creator>
    <dc:date>2018-09-22T13:28:57Z</dc:date>
    <item>
      <title>ifn susbtrn for multiple lengths</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/ifn-susbtrn-for-multiple-lengths/m-p/498067#M72486</link>
      <description>&lt;P&gt;I have the following code:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;data&lt;/STRONG&gt; a (drop=i);&lt;/P&gt;&lt;P&gt;&amp;nbsp; set b;&lt;/P&gt;&lt;P&gt;&amp;nbsp; array x{*} dx:;&lt;/P&gt;&lt;P&gt;hf=&lt;STRONG&gt;0&lt;/STRONG&gt;;&lt;/P&gt;&lt;P&gt;do i=&lt;STRONG&gt;1&lt;/STRONG&gt; to dim(x);&lt;/P&gt;&lt;P&gt;hf=ifn(substrn(x{i}, &lt;STRONG&gt;1&lt;/STRONG&gt;, &lt;STRONG&gt;3&lt;/STRONG&gt;) in('428', 'I43'),&lt;STRONG&gt;1&lt;/STRONG&gt;,hf);&lt;/P&gt;&lt;P&gt;end;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;data&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;a (drop=i);&lt;/P&gt;&lt;P&gt;&amp;nbsp; set b;&lt;/P&gt;&lt;P&gt;&amp;nbsp; array x{*} dx:;&lt;/P&gt;&lt;P&gt;hf=&lt;STRONG&gt;0&lt;/STRONG&gt;;&lt;/P&gt;&lt;P&gt;do i=&lt;STRONG&gt;1&lt;/STRONG&gt; to dim(x);&lt;/P&gt;&lt;P&gt;hf=ifn(substrn(x{i},&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;1&lt;/STRONG&gt;,&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;4&lt;/STRONG&gt;) in('d282', 'd432'),&lt;STRONG&gt;1&lt;/STRONG&gt;,hf);&lt;/P&gt;&lt;P&gt;end;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is there is a way to combine the two codes into one code given that I am requiring different lengths in the substrn&amp;nbsp;statement, (For example 3 in the first and 4 in the second).&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am looking to get a code that would be something&amp;nbsp;similar to:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;hf=ifn(substrn(x{i},&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;1&lt;/STRONG&gt;,&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;3&lt;/STRONG&gt;) in('428', 'I43'),&lt;STRONG&gt;1&lt;/STRONG&gt;,hf) or&amp;nbsp;&lt;SPAN&gt;hf=ifn(substrn(x{i},&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;1&lt;/STRONG&gt;&lt;SPAN&gt;,&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;4&lt;/STRONG&gt;&lt;SPAN&gt;) in('d282', 'd432'),&lt;/SPAN&gt;&lt;STRONG&gt;1&lt;/STRONG&gt;&lt;SPAN&gt;,hf);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Is it possible to have such statement?&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Thanks&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 22 Sep 2018 12:43:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/ifn-susbtrn-for-multiple-lengths/m-p/498067#M72486</guid>
      <dc:creator>lillymaginta</dc:creator>
      <dc:date>2018-09-22T12:43:47Z</dc:date>
    </item>
    <item>
      <title>Re: ifn susbtrn for multiple lengths</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/ifn-susbtrn-for-multiple-lengths/m-p/498070#M72487</link>
      <description>&lt;P&gt;have you tried:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;if hf=ifn(substrn(x{i},&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;1&lt;/STRONG&gt;&lt;SPAN&gt;,&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;3&lt;/STRONG&gt;&lt;SPAN&gt;) in('428', 'I43'),&lt;/SPAN&gt;&lt;STRONG&gt;1&lt;/STRONG&gt;&lt;SPAN&gt;,hf);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;else if &lt;/SPAN&gt;&lt;SPAN&gt;hf=ifn(substrn(x{i},&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;1&lt;/STRONG&gt;&lt;SPAN&gt;,&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;4&lt;/STRONG&gt;&lt;SPAN&gt;) in('d282', 'd432'),&lt;/SPAN&gt;&lt;STRONG&gt;1&lt;/STRONG&gt;&lt;SPAN&gt;,hf);&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 22 Sep 2018 12:52:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/ifn-susbtrn-for-multiple-lengths/m-p/498070#M72487</guid>
      <dc:creator>VDD</dc:creator>
      <dc:date>2018-09-22T12:52:18Z</dc:date>
    </item>
    <item>
      <title>Re: ifn susbtrn for multiple lengths</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/ifn-susbtrn-for-multiple-lengths/m-p/498071#M72488</link>
      <description>&lt;P&gt;Thank you VDD, the statement is not correct and would generate an error (no matching if-then clause)&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 22 Sep 2018 13:00:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/ifn-susbtrn-for-multiple-lengths/m-p/498071#M72488</guid>
      <dc:creator>lillymaginta</dc:creator>
      <dc:date>2018-09-22T13:00:23Z</dc:date>
    </item>
    <item>
      <title>Re: ifn susbtrn for multiple lengths</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/ifn-susbtrn-for-multiple-lengths/m-p/498072#M72489</link>
      <description>&lt;P&gt;does this link help:&lt;/P&gt;&lt;P&gt;&lt;A href="http://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a002604573.htm" target="_blank"&gt;http://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a002604573.htm&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 22 Sep 2018 13:07:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/ifn-susbtrn-for-multiple-lengths/m-p/498072#M72489</guid>
      <dc:creator>VDD</dc:creator>
      <dc:date>2018-09-22T13:07:18Z</dc:date>
    </item>
    <item>
      <title>Re: ifn susbtrn for multiple lengths</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/ifn-susbtrn-for-multiple-lengths/m-p/498073#M72490</link>
      <description>&lt;P&gt;Thank you for sharing the link. If I understand correctly, they did not use the else statement with "ifn" so I am not sure it is applicable here. Maybe one of the advisors can help (@RW9)&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 22 Sep 2018 13:28:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/ifn-susbtrn-for-multiple-lengths/m-p/498073#M72490</guid>
      <dc:creator>lillymaginta</dc:creator>
      <dc:date>2018-09-22T13:28:57Z</dc:date>
    </item>
    <item>
      <title>Re: ifn susbtrn for multiple lengths</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/ifn-susbtrn-for-multiple-lengths/m-p/498077#M72491</link>
      <description>&lt;P&gt;Not sure what you are trying to do but, if i do understand correctly, the following should work:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data b;
  input (dx1-dx5) ($);
  datalines;
d234 d463 d213 d282 d435
d213 428 d360 d145 d269
d409 d231 I43 d690 d432
234 463 213 678 435
213 428 360 145 269
409 231 I43 690 609
;
data a (drop=i);
  set b;
  array x{*} dx:;
  hf=0;
  do i=1 to dim(x);
    hf=ifn(substrn(x{i}, 1, 3) in('428', 'I43')
      or
           substrn(x{i}, 1, 4) in('d282', 'd432'),
    1,hf);
  end;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Art, CEO, AnalystFinder.com&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 22 Sep 2018 14:01:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/ifn-susbtrn-for-multiple-lengths/m-p/498077#M72491</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2018-09-22T14:01:41Z</dc:date>
    </item>
    <item>
      <title>Re: ifn susbtrn for multiple lengths</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/ifn-susbtrn-for-multiple-lengths/m-p/498080#M72493</link>
      <description>&lt;P&gt;Seems like you're making this too hard.&amp;nbsp; It would be helpful to see your input data.&amp;nbsp; I borrowed from &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13711"&gt;@art297&lt;/a&gt;&amp;nbsp;please indicate if that assumption is correct.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data b;
   id + 1;
   array dx[5] $8; 
   input dx[*];
   array _hf[4] $8 _temporary_ ('428' 'I43' 'd282' 'd432');
   array _st[2] $8 _temporary_ ('d269' '428');
   hf=0; st=0; 
   do i = 1 to dim(dx);;
      hf + dx[i] in _hf);
      st + dx[i] in _st);
      end;
   hf = hf gt 0;
   st = st gt 0;
   drop i;
   label hf='Heart Failure' st='Stroke';
   datalines;
d234 d463 d213 d282 d435
d213 428 d360 d145 d269
d409 d231 I43 d690 d432
234 463 213 678 435
213 428 360 145 269
409 231 I43 690 609
;;;;
   run;
proc print;
   run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Capture.PNG" style="width: 311px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/23461i56C53DCAE0ADA79E/image-size/large?v=v2&amp;amp;px=999" role="button" title="Capture.PNG" alt="Capture.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 22 Sep 2018 14:41:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/ifn-susbtrn-for-multiple-lengths/m-p/498080#M72493</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2018-09-22T14:41:23Z</dc:date>
    </item>
    <item>
      <title>Re: ifn susbtrn for multiple lengths</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/ifn-susbtrn-for-multiple-lengths/m-p/498081#M72494</link>
      <description>&lt;P&gt;Thank you!&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 22 Sep 2018 15:06:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/ifn-susbtrn-for-multiple-lengths/m-p/498081#M72494</guid>
      <dc:creator>lillymaginta</dc:creator>
      <dc:date>2018-09-22T15:06:46Z</dc:date>
    </item>
  </channel>
</rss>

