<?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 Trying to figure out the If then statements in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Trying-to-figure-out-the-If-then-statements/m-p/794586#M254790</link>
    <description>&lt;P&gt;When I type the following code and run it, I only get "excellent" or "Not so good" as my choices, not "good" or "okay" for the intended grades.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;1.Create a new dataset called ATL1 from the dataset ATLGRADES. In this data step, use IF-ELSE&lt;BR /&gt;statements to create a new character variable called GRADEREV with values of “Excellent” if&lt;BR /&gt;GRADE is between 85 and 100, “Good” if GRADE is between 70 and 84, “Okay” if GRADE is&lt;BR /&gt;between 60 and 69, and “Not so good” if GRADE is less than 60. Make sure you are using ELSE&lt;BR /&gt;statements here!;&lt;BR /&gt;data ATL1;&lt;BR /&gt;set Sarah.atlgrades;&lt;BR /&gt;if grade &amp;gt;= 85 then GRADEREV = "Excellent";&lt;BR /&gt;else if grade &amp;lt;= 70-84 then GRADEREV  = "Good";&lt;BR /&gt;else if grade &amp;lt;= 60-69 then GRADEREV  = "Okay";&lt;BR /&gt;else GRADEREV  = "Not so good";&lt;BR /&gt;run;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 04 Feb 2022 19:37:46 GMT</pubDate>
    <dc:creator>saza</dc:creator>
    <dc:date>2022-02-04T19:37:46Z</dc:date>
    <item>
      <title>Trying to figure out the If then statements</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Trying-to-figure-out-the-If-then-statements/m-p/794586#M254790</link>
      <description>&lt;P&gt;When I type the following code and run it, I only get "excellent" or "Not so good" as my choices, not "good" or "okay" for the intended grades.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;1.Create a new dataset called ATL1 from the dataset ATLGRADES. In this data step, use IF-ELSE&lt;BR /&gt;statements to create a new character variable called GRADEREV with values of “Excellent” if&lt;BR /&gt;GRADE is between 85 and 100, “Good” if GRADE is between 70 and 84, “Okay” if GRADE is&lt;BR /&gt;between 60 and 69, and “Not so good” if GRADE is less than 60. Make sure you are using ELSE&lt;BR /&gt;statements here!;&lt;BR /&gt;data ATL1;&lt;BR /&gt;set Sarah.atlgrades;&lt;BR /&gt;if grade &amp;gt;= 85 then GRADEREV = "Excellent";&lt;BR /&gt;else if grade &amp;lt;= 70-84 then GRADEREV  = "Good";&lt;BR /&gt;else if grade &amp;lt;= 60-69 then GRADEREV  = "Okay";&lt;BR /&gt;else GRADEREV  = "Not so good";&lt;BR /&gt;run;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 04 Feb 2022 19:37:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Trying-to-figure-out-the-If-then-statements/m-p/794586#M254790</guid>
      <dc:creator>saza</dc:creator>
      <dc:date>2022-02-04T19:37:46Z</dc:date>
    </item>
    <item>
      <title>Re: Trying to figure out the If then statements</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Trying-to-figure-out-the-If-then-statements/m-p/794591#M254791</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;else if grade &amp;lt;= 70-84 then GRADEREV  = "Good";&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;SAS interprets the code 70-84 to mean 70 minus 84, which is -14. So this tests if grade &amp;lt;= -14 then "Good". I don't think that's what you want.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Try this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;else if 70&amp;lt;=grade&amp;lt;=84 then graderev="Good";&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 04 Feb 2022 19:50:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Trying-to-figure-out-the-If-then-statements/m-p/794591#M254791</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2022-02-04T19:50:45Z</dc:date>
    </item>
    <item>
      <title>Re: Trying to figure out the If then statements</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Trying-to-figure-out-the-If-then-statements/m-p/794593#M254792</link>
      <description>Thank you so much! I did the same for 60-69 and that worked!</description>
      <pubDate>Fri, 04 Feb 2022 19:51:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Trying-to-figure-out-the-If-then-statements/m-p/794593#M254792</guid>
      <dc:creator>saza</dc:creator>
      <dc:date>2022-02-04T19:51:19Z</dc:date>
    </item>
  </channel>
</rss>

