<?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: can i have if statement with another if statement in it? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/can-i-have-if-statement-with-another-if-statement-in-it/m-p/572015#M161400</link>
    <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/274500"&gt;@Kayla_Tan222&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hi all, was wondering can I have a if statement, and then the program will run the if statement in it if the condition is fulfill with the first if statement?&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/274500"&gt;@Kayla_Tan222&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Yes, you can, but the condition "&lt;FONT face="courier new,courier"&gt;ratecde^=&amp;nbsp;&lt;/FONT&gt;" is incomplete: the "not equal" operator (&lt;FONT face="courier new,courier"&gt;^=&lt;/FONT&gt;) must be followed by a value, perhaps you mean a numeric missing value (denoted by a period) in this case:&amp;nbsp;&lt;FONT face="courier new,courier"&gt;ratecde^=&lt;FONT size="5" color="#0000FF"&gt;.&lt;/FONT&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;However, in this case and also with any other constant value (except 1000) that you might insert there, your initial IF condition would &lt;EM&gt;always&lt;/EM&gt; be met (and hence be redundant) because &lt;FONT face="courier new,courier"&gt;ratecde&lt;/FONT&gt; cannot equal 1000 and the other value at the same time.&lt;/P&gt;</description>
    <pubDate>Tue, 09 Jul 2019 12:13:54 GMT</pubDate>
    <dc:creator>FreelanceReinh</dc:creator>
    <dc:date>2019-07-09T12:13:54Z</dc:date>
    <item>
      <title>can i have if statement with another if statement in it?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/can-i-have-if-statement-with-another-if-statement-in-it/m-p/572005#M161394</link>
      <description>&lt;P&gt;Hi all, was wondering can I have a if statement, and then the program will run the if statement in it if the condition is fulfill with the first if statement?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here's my code below., but this is not work&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;if&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; ratecde^=&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;1000&lt;/FONT&gt;&lt;/STRONG&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;or&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; ratecde^=coin &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;or&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; ratecde^= &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;then&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;　&lt;/P&gt;&lt;P&gt;　&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;if test2=&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;10&lt;/FONT&gt;&lt;/STRONG&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;then&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;cov_type=&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;'MD1'&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;else&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;if&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; test2=&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;11&lt;/FONT&gt;&lt;/STRONG&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;then&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;cov_type=&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;'MD2'&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;else&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;if&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; test2=&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;12&lt;/FONT&gt;&lt;/STRONG&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;then&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;cov_type=&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;'MD3'&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;else&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;if&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; test2=&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;14&lt;/FONT&gt;&lt;/STRONG&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;then&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;cov_type=&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;'MD4'&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;else&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;if&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; test2=&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;29&lt;/FONT&gt;&lt;/STRONG&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;then&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;cov_type=&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;'MD5'&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;else&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;cov_type=&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;'MD6'&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;RUN&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 09 Jul 2019 11:41:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/can-i-have-if-statement-with-another-if-statement-in-it/m-p/572005#M161394</guid>
      <dc:creator>Kayla_Tan222</dc:creator>
      <dc:date>2019-07-09T11:41:53Z</dc:date>
    </item>
    <item>
      <title>Re: can i have if statement with another if statement in it?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/can-i-have-if-statement-with-another-if-statement-in-it/m-p/572007#M161396</link>
      <description>&lt;P&gt;What does the log say?&lt;/P&gt;</description>
      <pubDate>Tue, 09 Jul 2019 11:46:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/can-i-have-if-statement-with-another-if-statement-in-it/m-p/572007#M161396</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2019-07-09T11:46:00Z</dc:date>
    </item>
    <item>
      <title>Re: can i have if statement with another if statement in it?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/can-i-have-if-statement-with-another-if-statement-in-it/m-p/572008#M161397</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if ratecde^=1000 or ratecde^=coin or ratecde^= then do;
    if test2=10 then cov_type='MD1';
    else if test2=11 then cov_type='MD2';
    else if test2=12 then cov_type='MD3';
    else if test2=14 then cov_type='MD4';
    else if test2=29 then cov_type='MD5';
end;
else cov_type='MD6';

&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 09 Jul 2019 11:58:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/can-i-have-if-statement-with-another-if-statement-in-it/m-p/572008#M161397</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2019-07-09T11:58:26Z</dc:date>
    </item>
    <item>
      <title>Re: can i have if statement with another if statement in it?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/can-i-have-if-statement-with-another-if-statement-in-it/m-p/572012#M161399</link>
      <description>&lt;P&gt;As shown by &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/10892"&gt;@PaigeMiller&lt;/a&gt; , you have to enclose the instructions following your fisrt if by do; ... end;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can also avoid to use multiple if's by using a format :&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc format;
    value cov
        10="MD1"
        11="MD2"
        12="MD3"
        14="MD4"
        29="MD5"
        other="MD6"
    ;
run;

data have;
    do test2=10 to 30; 
        cov_type=put(test2,cov.);
        output;
    end;
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 09 Jul 2019 12:11:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/can-i-have-if-statement-with-another-if-statement-in-it/m-p/572012#M161399</guid>
      <dc:creator>gamotte</dc:creator>
      <dc:date>2019-07-09T12:11:29Z</dc:date>
    </item>
    <item>
      <title>Re: can i have if statement with another if statement in it?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/can-i-have-if-statement-with-another-if-statement-in-it/m-p/572015#M161400</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/274500"&gt;@Kayla_Tan222&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hi all, was wondering can I have a if statement, and then the program will run the if statement in it if the condition is fulfill with the first if statement?&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/274500"&gt;@Kayla_Tan222&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Yes, you can, but the condition "&lt;FONT face="courier new,courier"&gt;ratecde^=&amp;nbsp;&lt;/FONT&gt;" is incomplete: the "not equal" operator (&lt;FONT face="courier new,courier"&gt;^=&lt;/FONT&gt;) must be followed by a value, perhaps you mean a numeric missing value (denoted by a period) in this case:&amp;nbsp;&lt;FONT face="courier new,courier"&gt;ratecde^=&lt;FONT size="5" color="#0000FF"&gt;.&lt;/FONT&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;However, in this case and also with any other constant value (except 1000) that you might insert there, your initial IF condition would &lt;EM&gt;always&lt;/EM&gt; be met (and hence be redundant) because &lt;FONT face="courier new,courier"&gt;ratecde&lt;/FONT&gt; cannot equal 1000 and the other value at the same time.&lt;/P&gt;</description>
      <pubDate>Tue, 09 Jul 2019 12:13:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/can-i-have-if-statement-with-another-if-statement-in-it/m-p/572015#M161400</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2019-07-09T12:13:54Z</dc:date>
    </item>
  </channel>
</rss>

