<?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: Write multiple IF statements in more clever way+ connect it to macro var in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Write-multiple-IF-statements-in-more-clever-way-connect-it-to/m-p/621686#M182800</link>
    <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt;&amp;nbsp;- Love that term wallpaper code! Must add that to my lexicon.&lt;/P&gt;</description>
    <pubDate>Sat, 01 Feb 2020 21:07:30 GMT</pubDate>
    <dc:creator>SASKiwi</dc:creator>
    <dc:date>2020-02-01T21:07:30Z</dc:date>
    <item>
      <title>Write multiple IF statements in more clever way+ connect it to macro var</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Write-multiple-IF-statements-in-more-clever-way-connect-it-to/m-p/621655#M182779</link>
      <description>&lt;P&gt;Hello&lt;/P&gt;
&lt;P&gt;In my raw data I have information of failure for each customer.(Each customer has one row).&lt;/P&gt;
&lt;P&gt;For each customer there is a potential follow up of 15 months and we check If he/she touch failure at this period.&lt;/P&gt;
&lt;P&gt;Some of the customers didn't complete the full 15 months of following up periods.&lt;/P&gt;
&lt;P&gt;My question:&lt;/P&gt;
&lt;P&gt;I need to write 15 IF statements.&lt;/P&gt;
&lt;P&gt;What is the better way to do it?(More clever way)?&lt;/P&gt;
&lt;P&gt;It also might happen in the future that I need to run it on following up of different period...so maybe it is better to add a macro var&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%let k=15;&lt;/P&gt;
&lt;P&gt;that define the potential follow up period and then the IF statements will be adjusted automatic.&lt;/P&gt;
&lt;P&gt;Another question, Do you think that in this case I need to use "ELSE IF" statements or "IF"?(I know that result will be same but I want to ask what do you think)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;IF   No_Months_Exposed=15   then  Ind_Touch_Failure=MAX(OF grade1-grade15);							
ELSE IF   No_Months_Exposed=14   then  Ind_Touch_Failure=MAX(OF grade2-grade15);							
ELSE IF   No_Months_Exposed=13   then  Ind_Touch_Failure=MAX(OF grade3-grade15);							
ELSE IF   No_Months_Exposed=12  then  Ind_Touch_Failure=MAX(OF grade4-grade15);							
ELSE IF   No_Months_Exposed=11  then  Ind_Touch_Failure=MAX(OF grade5-grade15);							
ELSE IF   No_Months_Exposed=10  then  Ind_Touch_Failure=MAX(OF grade6-grade15);							
ELSE IF   No_Months_Exposed=9   then  Ind_Touch_Failure=MAX(OF grade7-grade15);							
ELSE IF   No_Months_Exposed=8   then  Ind_Touch_Failure=MAX(OF grade8-grade15);							
ELSE IF   No_Months_Exposed=7   then  Ind_Touch_Failure=MAX(OF grade9-grade15);							
ELSE IF   No_Months_Exposed=6   then  Ind_Touch_Failure=MAX(OF grade10-grade15);							
ELSE IF   No_Months_Exposed=5   then  Ind_Touch_Failure=MAX(OF grade11-grade15);							
ELSE IF   No_Months_Exposed=4   then  Ind_Touch_Failure=MAX(OF grade12-grade15);							
ELSE IF   No_Months_Exposed=3   then  Ind_Touch_Failure=MAX(OF grade13-grade15);							
ELSE IF   No_Months_Exposed=2   then  Ind_Touch_Failure=MAX(OF grade14-grade15);							
ELSE IF   No_Months_Exposed=1   then  Ind_Touch_Failure=MAX(OF grade15-grade15);							
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 01 Feb 2020 17:29:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Write-multiple-IF-statements-in-more-clever-way-connect-it-to/m-p/621655#M182779</guid>
      <dc:creator>Ronein</dc:creator>
      <dc:date>2020-02-01T17:29:56Z</dc:date>
    </item>
    <item>
      <title>Re: Write multiple IF statements in more clever way+ connect it to macro var</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Write-multiple-IF-statements-in-more-clever-way-connect-it-to/m-p/621657#M182780</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
%macro t;
 %do i=15 %to 1 %by -1;
  %let t= %eval(15-&amp;amp;i+1);
  %if &amp;amp;i&amp;lt;15 %then  else  ;
  if No_Months_Exposed=&amp;amp;i then Ind_Touch_Failure=MAX(OF grade&amp;amp;t-grade15);
 %end;
%mend t;



options mprint;
/*Call the macro*/
data want;
 set have;
 %t;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
117  options mprint;
118  /*Call the macro*/
119  data want;
120   set have;
121   %t;
MPRINT(T):   if No_Months_Exposed=15 then Ind_Touch_Failure=MAX(OF grade1-grade15);
MPRINT(T):   else if No_Months_Exposed=14 then Ind_Touch_Failure=MAX(OF grade2-grade15);
MPRINT(T):   else if No_Months_Exposed=13 then Ind_Touch_Failure=MAX(OF grade3-grade15);
MPRINT(T):   else if No_Months_Exposed=12 then Ind_Touch_Failure=MAX(OF grade4-grade15);
MPRINT(T):   else if No_Months_Exposed=11 then Ind_Touch_Failure=MAX(OF grade5-grade15);
MPRINT(T):   else if No_Months_Exposed=10 then Ind_Touch_Failure=MAX(OF grade6-grade15);
MPRINT(T):   else if No_Months_Exposed=9 then Ind_Touch_Failure=MAX(OF grade7-grade15);
MPRINT(T):   else if No_Months_Exposed=8 then Ind_Touch_Failure=MAX(OF grade8-grade15);
MPRINT(T):   else if No_Months_Exposed=7 then Ind_Touch_Failure=MAX(OF grade9-grade15);
MPRINT(T):   else if No_Months_Exposed=6 then Ind_Touch_Failure=MAX(OF grade10-grade15);
MPRINT(T):   else if No_Months_Exposed=5 then Ind_Touch_Failure=MAX(OF grade11-grade15);
MPRINT(T):   else if No_Months_Exposed=4 then Ind_Touch_Failure=MAX(OF grade12-grade15);
MPRINT(T):   else if No_Months_Exposed=3 then Ind_Touch_Failure=MAX(OF grade13-grade15);
MPRINT(T):   else if No_Months_Exposed=2 then Ind_Touch_Failure=MAX(OF grade14-grade15);
MPRINT(T):   else if No_Months_Exposed=1 then Ind_Touch_Failure=MAX(OF grade15-grade15);
122  run;

&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 01 Feb 2020 17:48:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Write-multiple-IF-statements-in-more-clever-way-connect-it-to/m-p/621657#M182780</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2020-02-01T17:48:16Z</dc:date>
    </item>
    <item>
      <title>Re: Write multiple IF statements in more clever way+ connect it to macro var</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Write-multiple-IF-statements-in-more-clever-way-connect-it-to/m-p/621658#M182781</link>
      <description>&lt;P&gt;Why not use an array to eliminate the need for the wallpaper code and hence any macro logic to generate the wallpaper code.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;array grade [15];
Ind_Touch_Failure=.;
do index=(15-No_Months_Exposed+1) to 15 ;
  Ind_Touch_Failure=max(Ind_Touch_Failure,grade[index]);
end;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 01 Feb 2020 17:55:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Write-multiple-IF-statements-in-more-clever-way-connect-it-to/m-p/621658#M182781</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2020-02-01T17:55:25Z</dc:date>
    </item>
    <item>
      <title>Re: Write multiple IF statements in more clever way+ connect it to macro var</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Write-multiple-IF-statements-in-more-clever-way-connect-it-to/m-p/621686#M182800</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt;&amp;nbsp;- Love that term wallpaper code! Must add that to my lexicon.&lt;/P&gt;</description>
      <pubDate>Sat, 01 Feb 2020 21:07:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Write-multiple-IF-statements-in-more-clever-way-connect-it-to/m-p/621686#M182800</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2020-02-01T21:07:30Z</dc:date>
    </item>
  </channel>
</rss>

