<?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: abnormal if then output in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/abnormal-if-then-output/m-p/934897#M367589</link>
    <description>&lt;P&gt;Hi &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/390518"&gt;@pavank&lt;/a&gt;, regarding the second question:&lt;/P&gt;
&lt;P&gt;Please read &lt;A href="https://communities.sas.com/t5/SAS-Programming/Difference-between-only-IF-with-and-IF-with-THEN-statement/td-p/245441" target="_blank"&gt;https://communities.sas.com/t5/SAS-Programming/Difference-between-only-IF-with-and-IF-with-THEN-statement/td-p/245441.&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;Your if statements select only the rowas with sex = "F" and (!) sex = "M".&lt;/P&gt;
&lt;P&gt;"and" and not "or". But there are now rows with sex = "F" and (!) sex = "M".&lt;/P&gt;
&lt;P&gt;Hope this answers your question.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best&lt;/P&gt;
&lt;P&gt;Markus&lt;/P&gt;</description>
    <pubDate>Sun, 07 Jul 2024 06:53:07 GMT</pubDate>
    <dc:creator>MarkusWeick</dc:creator>
    <dc:date>2024-07-07T06:53:07Z</dc:date>
    <item>
      <title>abnormal if then output</title>
      <link>https://communities.sas.com/t5/SAS-Programming/abnormal-if-then-output/m-p/934895#M367587</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/*Question_1 */&lt;BR /&gt;&lt;BR /&gt;data k;
x=2;
if x=1 then y=100;
if x=2 then y=200;
if x=3 then y=300;
else y=27;
run;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;/*Question_2&amp;nbsp;*/&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;data _n;&lt;BR /&gt;set sashelp.class;&lt;BR /&gt;if sex='F';&lt;BR /&gt;if sex='M' ;&lt;BR /&gt;put name sex ;&lt;BR /&gt;run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Hi Experts,&lt;/P&gt;
&lt;P&gt;Question_1&amp;nbsp; :Why it gives&amp;nbsp; &amp;nbsp;x=2 and y=27&amp;nbsp; why not y=200&amp;nbsp; &amp;nbsp;in k dataset&amp;nbsp; &amp;nbsp;could you please explain&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Question_2: Why zero observations in _n dataset&lt;/P&gt;</description>
      <pubDate>Sun, 07 Jul 2024 06:29:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/abnormal-if-then-output/m-p/934895#M367587</guid>
      <dc:creator>pavank</dc:creator>
      <dc:date>2024-07-07T06:29:31Z</dc:date>
    </item>
    <item>
      <title>Re: abnormal if then output</title>
      <link>https://communities.sas.com/t5/SAS-Programming/abnormal-if-then-output/m-p/934896#M367588</link>
      <description>&lt;P&gt;Hi &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/390518"&gt;@pavank&lt;/a&gt;, regarding question 1: the else relates only to the "if" which is before it. Try this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data k;
x=2;
if x=1 then y=100;
else
	if x=2 then y=200;
	else
		if x=3 then y=300;
		else y=27;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Mayve it gives the results you want.&lt;/P&gt;
&lt;P&gt;The comparison of this code and its results with the code and results of your question 1 should help to understand&amp;nbsp; how nested if else works.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best&lt;/P&gt;
&lt;P&gt;Markus&lt;/P&gt;</description>
      <pubDate>Sun, 07 Jul 2024 06:42:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/abnormal-if-then-output/m-p/934896#M367588</guid>
      <dc:creator>MarkusWeick</dc:creator>
      <dc:date>2024-07-07T06:42:16Z</dc:date>
    </item>
    <item>
      <title>Re: abnormal if then output</title>
      <link>https://communities.sas.com/t5/SAS-Programming/abnormal-if-then-output/m-p/934897#M367589</link>
      <description>&lt;P&gt;Hi &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/390518"&gt;@pavank&lt;/a&gt;, regarding the second question:&lt;/P&gt;
&lt;P&gt;Please read &lt;A href="https://communities.sas.com/t5/SAS-Programming/Difference-between-only-IF-with-and-IF-with-THEN-statement/td-p/245441" target="_blank"&gt;https://communities.sas.com/t5/SAS-Programming/Difference-between-only-IF-with-and-IF-with-THEN-statement/td-p/245441.&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;Your if statements select only the rowas with sex = "F" and (!) sex = "M".&lt;/P&gt;
&lt;P&gt;"and" and not "or". But there are now rows with sex = "F" and (!) sex = "M".&lt;/P&gt;
&lt;P&gt;Hope this answers your question.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best&lt;/P&gt;
&lt;P&gt;Markus&lt;/P&gt;</description>
      <pubDate>Sun, 07 Jul 2024 06:53:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/abnormal-if-then-output/m-p/934897#M367589</guid>
      <dc:creator>MarkusWeick</dc:creator>
      <dc:date>2024-07-07T06:53:07Z</dc:date>
    </item>
    <item>
      <title>Re: abnormal if then output</title>
      <link>https://communities.sas.com/t5/SAS-Programming/abnormal-if-then-output/m-p/934898#M367590</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/401244"&gt;@MarkusWeick&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you for your solution&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 07 Jul 2024 07:04:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/abnormal-if-then-output/m-p/934898#M367590</guid>
      <dc:creator>pavank</dc:creator>
      <dc:date>2024-07-07T07:04:32Z</dc:date>
    </item>
  </channel>
</rss>

