<?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: How to use IF/CASE statements in SAS EG? in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-use-IF-CASE-statements-in-SAS-EG/m-p/740141#M38779</link>
    <description>&lt;P&gt;The first step is always determining in your own mind (i.e. not even SAS code at this point) valid rules that will create these colors. I have added in red modifications to what you typed to produce valid rules&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;counter &amp;lt;&lt;FONT color="#FF0000"&gt;=&lt;/FONT&gt; (avg + std * 1)&lt;FONT color="#FF0000"&gt; then&lt;/FONT&gt; 'green'&lt;/P&gt;
&lt;P&gt;counter &amp;gt; (avg + std * 1) and &amp;lt;&lt;FONT color="#FF0000"&gt;=&lt;/FONT&gt; (avg +std * 2) &lt;FONT color="#FF0000"&gt;then&lt;/FONT&gt; 'yellow'&lt;/P&gt;
&lt;P&gt;counter &amp;gt; (avg + std * 2) and &lt;FONT color="#FF0000"&gt;&amp;lt;=&lt;/FONT&gt; (avg + std * 3)&lt;FONT color="#FF0000"&gt; then&lt;/FONT&gt; 'orange'&lt;BR /&gt;counter &amp;gt; (avg + std * 3) &lt;FONT color="#FF0000"&gt;then&lt;/FONT&gt; 'red'&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;From there, SAS code is relatively easy to produce.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
    set have;
    length color $ 6;
    if counter &amp;lt;= (avg + std * 1) then color= 'green';
    else if counter &amp;gt; (avg + std * 1) and counter &amp;lt;= (avg +std * 2) then color='yellow';
    else if counter &amp;gt; (avg + std * 2) and counter &amp;lt;= (avg + std * 3) then color= 'orange';
    else if counter &amp;gt; (avg + std * 3) then color= 'red';
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;There are some minor simplications you can make to the above, such as changing the next to last line to&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;else color='red';&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, 10 May 2021 11:49:23 GMT</pubDate>
    <dc:creator>PaigeMiller</dc:creator>
    <dc:date>2021-05-10T11:49:23Z</dc:date>
    <item>
      <title>How to use IF/CASE statements in SAS EG?</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-use-IF-CASE-statements-in-SAS-EG/m-p/740137#M38778</link>
      <description>&lt;P&gt;I have a dataset which looks like this.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
infile datalines truncover;
input type $ quarter phase counter percent avg std;
datalines;
XX-A 202001 1 30 20 20 1
XX-A 202002 1 50 2 20 1
XX-A 202003 1 60 2 20 2
XX-A 202004 1 50 10 20 2
XX-B 202001 2 30 4 30 3
XX-B 202002 2 60 4 30 3
XX-B 202003 2 70 1 30 3
XX-B 202004 2 20 3 30 3&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;STRONG&gt;I want to create a new column named STATUS based on the following if/case statements:&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;If count is &amp;lt; (avg + std * 1) = 'green'&lt;/P&gt;
&lt;P&gt;if count &amp;gt; (avg + std * 1) and &amp;lt; (avg +std * 2) = 'yellow'&lt;/P&gt;
&lt;P&gt;if count &amp;gt; (avg + std * 2) and (avg + std * 3) = 'orange'&lt;BR /&gt;if count &amp;gt; (avg + std * 3) = 'red'&lt;/P&gt;</description>
      <pubDate>Mon, 10 May 2021 11:35:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-use-IF-CASE-statements-in-SAS-EG/m-p/740137#M38778</guid>
      <dc:creator>Andalusia</dc:creator>
      <dc:date>2021-05-10T11:35:59Z</dc:date>
    </item>
    <item>
      <title>Re: How to use IF/CASE statements in SAS EG?</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-use-IF-CASE-statements-in-SAS-EG/m-p/740141#M38779</link>
      <description>&lt;P&gt;The first step is always determining in your own mind (i.e. not even SAS code at this point) valid rules that will create these colors. I have added in red modifications to what you typed to produce valid rules&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;counter &amp;lt;&lt;FONT color="#FF0000"&gt;=&lt;/FONT&gt; (avg + std * 1)&lt;FONT color="#FF0000"&gt; then&lt;/FONT&gt; 'green'&lt;/P&gt;
&lt;P&gt;counter &amp;gt; (avg + std * 1) and &amp;lt;&lt;FONT color="#FF0000"&gt;=&lt;/FONT&gt; (avg +std * 2) &lt;FONT color="#FF0000"&gt;then&lt;/FONT&gt; 'yellow'&lt;/P&gt;
&lt;P&gt;counter &amp;gt; (avg + std * 2) and &lt;FONT color="#FF0000"&gt;&amp;lt;=&lt;/FONT&gt; (avg + std * 3)&lt;FONT color="#FF0000"&gt; then&lt;/FONT&gt; 'orange'&lt;BR /&gt;counter &amp;gt; (avg + std * 3) &lt;FONT color="#FF0000"&gt;then&lt;/FONT&gt; 'red'&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;From there, SAS code is relatively easy to produce.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
    set have;
    length color $ 6;
    if counter &amp;lt;= (avg + std * 1) then color= 'green';
    else if counter &amp;gt; (avg + std * 1) and counter &amp;lt;= (avg +std * 2) then color='yellow';
    else if counter &amp;gt; (avg + std * 2) and counter &amp;lt;= (avg + std * 3) then color= 'orange';
    else if counter &amp;gt; (avg + std * 3) then color= 'red';
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;There are some minor simplications you can make to the above, such as changing the next to last line to&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;else color='red';&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, 10 May 2021 11:49:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-use-IF-CASE-statements-in-SAS-EG/m-p/740141#M38779</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2021-05-10T11:49:23Z</dc:date>
    </item>
  </channel>
</rss>

