<?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 Proc SQL - IF/THEN Conditions in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Proc-SQL-IF-THEN-Conditions/m-p/412046#M26469</link>
    <description>&lt;DIV class="g-unit"&gt;&lt;DIV&gt;&lt;DIV class=""&gt;&lt;DIV&gt;I need to make a condition where if time is &amp;lt;= 09:00 then 1;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;if time is &amp;gt;&amp;nbsp;&lt;/SPAN&gt;09:00 and &amp;lt; 17:00 then 2 and if &amp;gt; 17:00 then 3.&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
    <pubDate>Thu, 09 Nov 2017 17:30:01 GMT</pubDate>
    <dc:creator>eduardo_pedrosa</dc:creator>
    <dc:date>2017-11-09T17:30:01Z</dc:date>
    <item>
      <title>Proc SQL - IF/THEN Conditions</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Proc-SQL-IF-THEN-Conditions/m-p/412046#M26469</link>
      <description>&lt;DIV class="g-unit"&gt;&lt;DIV&gt;&lt;DIV class=""&gt;&lt;DIV&gt;I need to make a condition where if time is &amp;lt;= 09:00 then 1;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;if time is &amp;gt;&amp;nbsp;&lt;/SPAN&gt;09:00 and &amp;lt; 17:00 then 2 and if &amp;gt; 17:00 then 3.&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Thu, 09 Nov 2017 17:30:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Proc-SQL-IF-THEN-Conditions/m-p/412046#M26469</guid>
      <dc:creator>eduardo_pedrosa</dc:creator>
      <dc:date>2017-11-09T17:30:01Z</dc:date>
    </item>
    <item>
      <title>Re: Proc SQL - IF/THEN Conditions</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Proc-SQL-IF-THEN-Conditions/m-p/412075#M26470</link>
      <description>&lt;P&gt;I would guess a CASE statement would get it done, but if all you are doing is setting a flag, I would be tempted to do it in the data step (and this is coming from an SQL guy).&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;data mytimes;
   input id time time.;
datalines;
1105 08:00
1106 08:30
1107 09:10
1108 10:10
1109 12:56
1110 16:59
1111 17:01
1112 23:45
;
run;

* method 1;
data mytime_flags;
	set mytimes;
	mytimeflag= 0;
	if time &amp;lt;= '09:00't then mytimeflag = 1;
	if time &amp;gt; '09:00't and time &amp;lt; '17:00't then mytimeflag = 2;
	if time &amp;gt;= '17:00't then mytimeflag = 3;
run;

*method 2;
proc sql;
	create table mytime_flags2 as 
	select id, time,
	case 
	when time &amp;lt;= '09:00't then 1
	when time &amp;gt; '09:00't and time &amp;lt; '17:00't then 2
	when time &amp;gt;= '17:00't then 3
	end as mytimeflag
	from mytimes;
quit;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 09 Nov 2017 19:08:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Proc-SQL-IF-THEN-Conditions/m-p/412075#M26470</guid>
      <dc:creator>HB</dc:creator>
      <dc:date>2017-11-09T19:08:45Z</dc:date>
    </item>
  </channel>
</rss>

