<?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: multiple if then else statements using a do loop in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/multiple-if-then-else-statements-using-a-do-loop/m-p/400368#M97061</link>
    <description>thank you. That solved the error message. I ran the code again and it looks like my code worked except the situation where all the treatments are no. Those have a blank for the priorrx field.</description>
    <pubDate>Mon, 02 Oct 2017 17:56:34 GMT</pubDate>
    <dc:creator>PaulaC</dc:creator>
    <dc:date>2017-10-02T17:56:34Z</dc:date>
    <item>
      <title>multiple if then else statements using a do loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/multiple-if-then-else-statements-using-a-do-loop/m-p/400333#M97056</link>
      <description>&lt;P&gt;I have five different treatments for the patients in my dataset.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to create a prior treatment variable that has the following&amp;nbsp;response options: surgery+other treatment, immunotherapy+other treatment, radiotherapy+other treatment, chemotherapy+hormonal treatment, surgery, immunotherapy, radiotherapy, chemotherapy, hormonal treament, none of listed treatments.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would like my data to look similar to the data below:&lt;/P&gt;&lt;P&gt;Pt #&amp;nbsp; surgery&amp;nbsp; immunerx&amp;nbsp; radiotherapy&amp;nbsp; chemotherapy&amp;nbsp; hormonal&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; priorrx&lt;/P&gt;&lt;P&gt;1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; yes&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; yes&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;no&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; yes&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;no&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; surgery+other treatment&lt;/P&gt;&lt;P&gt;2&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; yes&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; no&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; yes&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;no&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;no&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; surgery+other treatment&lt;/P&gt;&lt;P&gt;3&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; yes&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; no&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;no&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;no&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;no&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;surgery&lt;/P&gt;&lt;P&gt;4&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;no&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;yes&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;yes&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;yes&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;no&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;immunerx+other treatment&lt;/P&gt;&lt;P&gt;5&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;no&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;yes&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; no&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;no&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;no&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; immunerx&lt;/P&gt;&lt;P&gt;6&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; no&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; no&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;yes&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; no&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; no&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;radiotherapy&lt;/P&gt;&lt;P&gt;and so on...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a variable for surgery, immunotherapy, radiotherapy, chemotherapy and hormonal therapy with response options of Yes/No.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I was trying to create a do loop to cover all the different permutations and combinations.&amp;nbsp; I am getting a note and errors in the log.&amp;nbsp; I feel like it must be something simple, but can't figure out what I am doing wrong.&amp;nbsp; In my code the else if statements are colored purple.&amp;nbsp; I know that something is wrong based on that also.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please find the portion of the log below with the errors and notes:&lt;/P&gt;&lt;P&gt;2705 *-----------------;&lt;BR /&gt;2706 *calculate priorrx;&lt;BR /&gt;2707 *-----------------;&lt;BR /&gt;2708&lt;BR /&gt;2709 if surgery='Yes' or immunerx='Yes' or&lt;BR /&gt;2709! radiotherapy='Yes' or chemotherapy='Yes' or hormonal='Yes'&lt;BR /&gt;2709! then do;&lt;BR /&gt;2710 if surgery='Yes and (immunerx='Yes' or&lt;BR /&gt;--------------------&lt;BR /&gt;-------------------&lt;BR /&gt;-------------------&lt;BR /&gt;---------------&lt;BR /&gt;-----------------&lt;BR /&gt;---------------------------&lt;BR /&gt;49 49&lt;BR /&gt;49&lt;BR /&gt;49&lt;BR /&gt;49&lt;BR /&gt;49&lt;BR /&gt;---&lt;BR /&gt;388&lt;BR /&gt;---&lt;BR /&gt;76&lt;BR /&gt;2710! radiotherapy='Yes' or chemotherapy='Yes' or&lt;BR /&gt;2710! hormonal='Yes') then priorrx='surgery+other treatment';&lt;BR /&gt;2711 else if surgery='Yes' and (immunerx='No' and&lt;BR /&gt;2711! radiotherapy='No' and chemotherapy='No' and&lt;BR /&gt;2711! hormonal='No') then priorrx='surgery';&lt;BR /&gt;-----------------&lt;BR /&gt;49&lt;BR /&gt;NOTE 49-169: The meaning of an identifier after a quoted string&lt;BR /&gt;might change in a future SAS release. Inserting&lt;BR /&gt;white space between a quoted string and the&lt;BR /&gt;succeeding identifier is recommended.&lt;/P&gt;&lt;P&gt;ERROR 388-185: Expecting an arithmetic operator.&lt;/P&gt;&lt;P&gt;ERROR 76-322: Syntax error, statement will be ignored.&lt;/P&gt;&lt;P&gt;2712&lt;BR /&gt;2713 else if surgery='No' and immunerx='Yes' and&lt;BR /&gt;----------------&lt;BR /&gt;---------------------&lt;BR /&gt;-------------------&lt;BR /&gt;---------------&lt;BR /&gt;-----------------&lt;BR /&gt;----------------------------&lt;BR /&gt;49 49&lt;BR /&gt;49&lt;BR /&gt;49&lt;BR /&gt;49&lt;BR /&gt;49&lt;BR /&gt;2713! (radiotherapy='Yes' or chemotherapy='Yes' or&lt;BR /&gt;2713! hormonal='Yes') then priorrx='immunotherapy+other&lt;BR /&gt;2713! treatment';&lt;BR /&gt;2714 else if immunerx='Yes' and (radiotherapy='No' and&lt;BR /&gt;2714! chemotherapy='No' and hormonal='No') then&lt;BR /&gt;------------------&lt;BR /&gt;49&lt;BR /&gt;2714! priorrx='immunotherapy';&lt;BR /&gt;NOTE 49-169: The meaning of an identifier after a quoted string&lt;BR /&gt;might change in a future SAS release. Inserting&lt;BR /&gt;white space between a quoted string and the&lt;BR /&gt;succeeding identifier is recommended.&lt;/P&gt;&lt;P&gt;2715&lt;BR /&gt;2716 else if immunerx='No' and radiotherapy='Yes' and&lt;BR /&gt;--------------------&lt;BR /&gt;---------------------&lt;BR /&gt;---------------&lt;BR /&gt;-----------------&lt;BR /&gt;--------------------------------&lt;BR /&gt;49 49&lt;BR /&gt;49&lt;BR /&gt;49&lt;BR /&gt;49&lt;BR /&gt;2716! (chemotherapy='Yes' or hormonal='Yes') then&lt;BR /&gt;2716! priorrx='radiotherapy+other treatment';&lt;BR /&gt;2717 else if radiotherapy='Yes' and (chemotherapy='No'&lt;BR /&gt;2717! and hormonal='No') then priorrx='radiotherapy';&lt;BR /&gt;-----------------&lt;BR /&gt;49&lt;BR /&gt;NOTE 49-169: The meaning of an identifier after a quoted string&lt;BR /&gt;might change in a future SAS release. Inserting&lt;BR /&gt;white space between a quoted string and the&lt;BR /&gt;succeeding identifier is recommended.&lt;/P&gt;&lt;P&gt;2718&lt;BR /&gt;2719 else if radiotherapy='No' and chemotherapy='Yes' and&lt;BR /&gt;--------------------&lt;BR /&gt;----------------&lt;BR /&gt;----------------&lt;BR /&gt;--------------------------------&lt;BR /&gt;49 49&lt;BR /&gt;49&lt;BR /&gt;49&lt;BR /&gt;2719! hormonal='Yes' then priorrx='chemotherapy+hormonal&lt;BR /&gt;2719! treatment';&lt;BR /&gt;2720 else if chemotherapy='Yes' and homronal='No'&lt;/P&gt;&lt;P&gt;----------------&lt;BR /&gt;49&lt;BR /&gt;2720! then priorrx='chemotherapy';&lt;BR /&gt;NOTE 49-169: The meaning of an identifier after a quoted string&lt;BR /&gt;might change in a future SAS release. Inserting&lt;BR /&gt;white space between a quoted string and the&lt;BR /&gt;succeeding identifier is recommended.&lt;/P&gt;&lt;P&gt;2721&lt;BR /&gt;2722 else if chemotherapy='No' and hormonal='Yes' then&lt;BR /&gt;----------------&lt;BR /&gt;----------------&lt;BR /&gt;49 49&lt;BR /&gt;2722! priorrx='hormonal treatment';&lt;BR /&gt;NOTE 49-169: The meaning of an identifier after a quoted string&lt;BR /&gt;might change in a future SAS release. Inserting&lt;BR /&gt;white space between a quoted string and the&lt;BR /&gt;succeeding identifier is recommended.&lt;/P&gt;&lt;P&gt;2723&lt;BR /&gt;2724 else priorrx='none of listed treatments';&lt;BR /&gt;2725&lt;BR /&gt;2726 end;&lt;BR /&gt;2727&lt;BR /&gt;&lt;BR /&gt;--&lt;BR /&gt;49&lt;BR /&gt;NOTE 49-169: The meaning of an identifier after a quoted string&lt;BR /&gt;might change in a future SAS release. Inserting&lt;BR /&gt;white space between a quoted string and the&lt;BR /&gt;succeeding identifier is recommended.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any help that could be provided would be greatly appreciated.&amp;nbsp; I am using SAS 9.4 TS Level 1M3.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 02 Oct 2017 16:58:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/multiple-if-then-else-statements-using-a-do-loop/m-p/400333#M97056</guid>
      <dc:creator>PaulaC</dc:creator>
      <dc:date>2017-10-02T16:58:03Z</dc:date>
    </item>
    <item>
      <title>Re: multiple if then else statements using a do loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/multiple-if-then-else-statements-using-a-do-loop/m-p/400335#M97057</link>
      <description>&lt;P&gt;Post the actual code used please.&lt;/P&gt;</description>
      <pubDate>Mon, 02 Oct 2017 17:00:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/multiple-if-then-else-statements-using-a-do-loop/m-p/400335#M97057</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-10-02T17:00:05Z</dc:date>
    </item>
    <item>
      <title>Re: multiple if then else statements using a do loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/multiple-if-then-else-statements-using-a-do-loop/m-p/400341#M97058</link>
      <description>&lt;P&gt;The immediate problem is that you are missing a closing quote here:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;2710 if surgery='Yes and&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Sometimes when you fix one problem, it reveals another.&amp;nbsp; We'll have to wait and see.&lt;/P&gt;</description>
      <pubDate>Mon, 02 Oct 2017 17:22:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/multiple-if-then-else-statements-using-a-do-loop/m-p/400341#M97058</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2017-10-02T17:22:05Z</dc:date>
    </item>
    <item>
      <title>Re: multiple if then else statements using a do loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/multiple-if-then-else-statements-using-a-do-loop/m-p/400368#M97061</link>
      <description>thank you. That solved the error message. I ran the code again and it looks like my code worked except the situation where all the treatments are no. Those have a blank for the priorrx field.</description>
      <pubDate>Mon, 02 Oct 2017 17:56:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/multiple-if-then-else-statements-using-a-do-loop/m-p/400368#M97061</guid>
      <dc:creator>PaulaC</dc:creator>
      <dc:date>2017-10-02T17:56:34Z</dc:date>
    </item>
    <item>
      <title>Re: multiple if then else statements using a do loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/multiple-if-then-else-statements-using-a-do-loop/m-p/400375#M97065</link>
      <description>&lt;P&gt;Please find the actual code below:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data analysis;&lt;BR /&gt;retain blind studyid usubjid siteid racegr1 racegrp country cntrygrp age visceral nonvisceral;&lt;BR /&gt;length totcomorbid racegrp cntrygrp $20 visit combined_site totmetsites $200;&lt;BR /&gt;set analysisallp1 analysisallp2;&lt;BR /&gt;where itt='Yes';&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;if comorbid=0 then totcomorbid='0';&lt;BR /&gt;else if comorbid=1 then totcomorbid='1';&lt;BR /&gt;else totcomorbid='2 or more';&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;if ^missing(orgnnuminv) then do;&lt;BR /&gt;if orgnnuminv = 0 or orgnnuminv=1 then totmetsites = '0 to 1';&lt;BR /&gt;else if orgnnuminv&amp;gt;1 then totmetsites='2 and above';&lt;BR /&gt;end;&lt;BR /&gt;else totmetsites = 'Missing';&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;*-----------------;&lt;BR /&gt;*calculate priorrx;&lt;BR /&gt;*-----------------;&lt;/P&gt;&lt;P&gt;if surgery='Yes' or immunerx='Yes' or radiotherapy='Yes' or chemotherapy='Yes' or hormonal='Yes' then do;&lt;BR /&gt;if surgery='Yes' and (immunerx='Yes' or radiotherapy='Yes' or chemotherapy='Yes' or hormonal='Yes') then priorrx='surgery+other treatment';&lt;BR /&gt;else if surgery='Yes' and (immunerx='No' and radiotherapy='No' and chemotherapy='No' and hormonal='No') then priorrx='surgery';&lt;BR /&gt;&lt;BR /&gt;else if surgery='No' and immunerx='Yes' and (radiotherapy='Yes' or chemotherapy='Yes' or hormonal='Yes') then priorrx='immunotherapy+other treatment';&lt;BR /&gt;else if immunerx='Yes' and (radiotherapy='No' and chemotherapy='No' and hormonal='No') then priorrx='immunotherapy';&lt;BR /&gt;&lt;BR /&gt;else if immunerx='No' and radiotherapy='Yes' and (chemotherapy='Yes' or hormonal='Yes') then priorrx='radiotherapy+other treatment';&lt;BR /&gt;else if radiotherapy='Yes' and (chemotherapy='No' and hormonal='No') then priorrx='radiotherapy';&lt;/P&gt;&lt;P&gt;else if radiotherapy='No' and chemotherapy='Yes' and hormonal='Yes' then priorrx='chemotherapy+hormonal treatment';&lt;BR /&gt;else if chemotherapy='Yes' and hormonal='No' then priorrx='chemotherapy';&lt;/P&gt;&lt;P&gt;else if chemotherapy='No' and hormonal='Yes' then priorrx='hormonal treatment';&lt;BR /&gt;&lt;BR /&gt;else priorrx='none of listed treatments';&lt;/P&gt;&lt;P&gt;end;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;label OVRLRESP="Visit Overall Response-INV"&lt;BR /&gt;risk="Prognostic risk level"&lt;BR /&gt;icmstdtn="Imputed conmed start date (numeric)"&lt;BR /&gt;icmendtn="Imputed conmed end date (numeric)";&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I think I figured out the issue.&amp;nbsp; I think the else statement needs to go afte the end statement, if my thinking is correct.&lt;/P&gt;</description>
      <pubDate>Mon, 02 Oct 2017 18:06:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/multiple-if-then-else-statements-using-a-do-loop/m-p/400375#M97065</guid>
      <dc:creator>PaulaC</dc:creator>
      <dc:date>2017-10-02T18:06:49Z</dc:date>
    </item>
    <item>
      <title>Re: multiple if then else statements using a do loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/multiple-if-then-else-statements-using-a-do-loop/m-p/400388#M97069</link>
      <description>&lt;P&gt;I woudl not want to track all that branching and elses and else ifs.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I would be more likely to do something like:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if surgery = 'Yes' and (immunerx = 'No' and radiotherapy = 'No' and chemotherapy = 'No'
                   and hormonal = 'No') then priorrx = 'Surgery';
if surgery = 'Yes' and (immunerx = 'Yes' or radiotherapy = 'Yes' or chemotherapy = 'Yes'
                   or hormonal = 'Yes') then priorrx = 'Surgery plus other treatment';
if surgery = 'No' and immunerx = 'Yes' and (radiotherapy = 'No' and chemotherapy = 'No'
                   and hormonal = 'No') then priorrx = 'Immunerx';
if surgery = 'No' and immunerx = 'Yes' and (radiotherapy = 'Yes' or chemotherapy = 'Yes'
                   or hormonal = 'Yes') then priorrx = 'Immunerx plus other treatment';
if surgery = 'No' and immunerx = 'No' and radiotherapy = 'Yes' and (chemotherapy = 'No'
                   and hormonal = 'No') then priorrx = 'radiotherapy';
if surgery = 'No' and immunerx = 'No' and radiotherapy = 'Yes' and (chemotherapy = 'Yes'
                   or hormonal = 'Yes') then priorrx = 'Radiotherapy plus other treatment';
   &lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;etc&lt;/P&gt;</description>
      <pubDate>Mon, 02 Oct 2017 18:53:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/multiple-if-then-else-statements-using-a-do-loop/m-p/400388#M97069</guid>
      <dc:creator>HB</dc:creator>
      <dc:date>2017-10-02T18:53:39Z</dc:date>
    </item>
    <item>
      <title>Re: multiple if then else statements using a do loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/multiple-if-then-else-statements-using-a-do-loop/m-p/400440#M97077</link>
      <description>&lt;P&gt;100% correct.&amp;nbsp; Switch the order of these two:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;else priorrx='none of listed treatments';&lt;/P&gt;
&lt;P&gt;end;&lt;/P&gt;</description>
      <pubDate>Mon, 02 Oct 2017 20:10:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/multiple-if-then-else-statements-using-a-do-loop/m-p/400440#M97077</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2017-10-02T20:10:50Z</dc:date>
    </item>
    <item>
      <title>Re: multiple if then else statements using a do loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/multiple-if-then-else-statements-using-a-do-loop/m-p/400445#M97079</link>
      <description>&lt;P&gt;I've been known to build a text variable consisting of 1 and 0 for Yes and No in order for a list of variables and then using a custom format to display the value.&lt;/P&gt;
&lt;P&gt;A brief example:&lt;/P&gt;
&lt;PRE&gt;Proc format library=work;
value $FakeBinary
'11' = 'Both Yes'
'10' = 'Only first Yes'
'01' = 'Only 2nd Yes'
'00' = 'Both No'
;
run;


data junk;
   input v1 $ v2 $;
   FakeBin = cats(v1='Yes',v2='Yes');
   format FakeBin FakeBinary.;
datalines;
Yes Yes
Yes No
No  Yes
No  No
;
run;&lt;/PRE&gt;
&lt;P&gt;Of course the real world does need to consider the cases where one of your dichotomous Yes/No variables is actually missing as well if that is possible.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The format approach I find useful because I know that if I have 4 variables that I need to 2**4 cases and if the combinations get a bit tricky then the IF/Then/Else code can be come very complex. But in a format I can have the values laid out nicely so that I can see that the first, third and 5th items are all 1 and assign the formatted value easily. (Yes 5 variables means 32 possibilities to consider)&lt;/P&gt;</description>
      <pubDate>Mon, 02 Oct 2017 20:22:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/multiple-if-then-else-statements-using-a-do-loop/m-p/400445#M97079</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2017-10-02T20:22:19Z</dc:date>
    </item>
    <item>
      <title>Re: multiple if then else statements using a do loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/multiple-if-then-else-statements-using-a-do-loop/m-p/400446#M97080</link>
      <description>&lt;P&gt;I&amp;nbsp;don't like using that many nested if-statements.&amp;nbsp;In the past various flags were stored in a single numeric variable, to save memory. So, i translated the "Yes" to 1 and "No" to 0, concatenated the 1s and 0s and used a format to get the requested text. The data-step has been reduced to the creation of&amp;nbsp;priorrx.&lt;/P&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;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc format;
   value priorrxFmt
      1 = 'hormonal treatment'
      2 = 'chemotherapy'
      3 = 'chemotherapy+other treatment'
      4 = 'radiotherapy'
      5-7 = 'radiotherapy+other treatment'
      8 = 'immunotherapy'
      9-15 = 'immunotherapy+other treatment'
      16 = 'Surgery'
      17-31 = 'Surgery+other treatment'
      other = 'none of listed treatments'
   ;
run;

data want;
   length binaryString $ 5 priorrx $ 40;
   set have;
   
   array t surgery immunerx radiotherapy chemotherapy hormonal;
   
   do i = 1 to dim(t);
      binaryString = cats(binaryString, ifc(t{i} = 'Yes', '1', '0'));
   end;
   
   priorrx = put(input(binaryString, binary5.), priorrxFmt.);
   
   drop binaryString;
run;

&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 02 Oct 2017 20:24:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/multiple-if-then-else-statements-using-a-do-loop/m-p/400446#M97080</guid>
      <dc:creator>error_prone</dc:creator>
      <dc:date>2017-10-02T20:24:13Z</dc:date>
    </item>
    <item>
      <title>Re: multiple if then else statements using a do loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/multiple-if-then-else-statements-using-a-do-loop/m-p/400505#M97090</link>
      <description>thank you for your suggestion.</description>
      <pubDate>Tue, 03 Oct 2017 02:26:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/multiple-if-then-else-statements-using-a-do-loop/m-p/400505#M97090</guid>
      <dc:creator>PaulaC</dc:creator>
      <dc:date>2017-10-03T02:26:34Z</dc:date>
    </item>
    <item>
      <title>Re: multiple if then else statements using a do loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/multiple-if-then-else-statements-using-a-do-loop/m-p/400506#M97091</link>
      <description>thank you for your suggestion and comment. I had not thought of doing it that way. Good to know.</description>
      <pubDate>Tue, 03 Oct 2017 02:28:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/multiple-if-then-else-statements-using-a-do-loop/m-p/400506#M97091</guid>
      <dc:creator>PaulaC</dc:creator>
      <dc:date>2017-10-03T02:28:20Z</dc:date>
    </item>
    <item>
      <title>Re: multiple if then else statements using a do loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/multiple-if-then-else-statements-using-a-do-loop/m-p/400507#M97092</link>
      <description>thank you. This is another interesting way of creating the combinations I have. Appreciate the example and code.</description>
      <pubDate>Tue, 03 Oct 2017 02:29:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/multiple-if-then-else-statements-using-a-do-loop/m-p/400507#M97092</guid>
      <dc:creator>PaulaC</dc:creator>
      <dc:date>2017-10-03T02:29:32Z</dc:date>
    </item>
  </channel>
</rss>

