<?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: IF statement is not recognized (black font), whereas THEN and ELSE is recognized (blue font) in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/IF-statement-is-not-recognized-black-font-whereas-THEN-and-ELSE/m-p/261366#M50849</link>
    <description>&lt;P&gt;FORMAT works in a data step, but PROC IMPORT is a helper procedure that looks at the data, makes more or less educated guesses about the strcuture and then creates and runs a data step from that. Only 4 statements are valid within PROC IMPORT: DLM=, DATAROW=, GUESSINGROWS=, GETNAMES=.&lt;/P&gt;
&lt;P&gt;To force formats, one can take the data step that IMPORT creates from the log and modify that.&lt;/P&gt;</description>
    <pubDate>Tue, 05 Apr 2016 13:07:17 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2016-04-05T13:07:17Z</dc:date>
    <item>
      <title>IF statement is not recognized (black font), whereas THEN and ELSE is recognized (blue font)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/IF-statement-is-not-recognized-black-font-whereas-THEN-and-ELSE/m-p/261328#M50824</link>
      <description>&lt;P&gt;When an employee opens a dossier, a few tasks are created automatically. These tasks receive a sequence number (1 to 5) indicating in which order they need to be performed. Only one task can be active while the others are waiting. When a task is completed it becomes done, unless they cancel it. Each task has a start date, a close date and a deadline depending on each task.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I received an Excel file which contains task_handler (employee), object_name (title of the task), start_date, close_date, deadline, task_state and sequence.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;object_name&lt;/TD&gt;&lt;TD&gt;deadline&lt;/TD&gt;&lt;TD&gt;start_date&lt;/TD&gt;&lt;TD&gt;close_date&lt;/TD&gt;&lt;TD&gt;task_handler&lt;/TD&gt;&lt;TD&gt;task_state&lt;/TD&gt;&lt;TD&gt;sequence&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Intake&lt;/TD&gt;&lt;TD&gt;8/03/2016&lt;/TD&gt;&lt;TD&gt;1/03/2016&lt;/TD&gt;&lt;TD&gt;7/03/2016&lt;/TD&gt;&lt;TD&gt;Handler A&lt;/TD&gt;&lt;TD&gt;DONE&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Intake&lt;/TD&gt;&lt;TD&gt;8/03/2016&lt;/TD&gt;&lt;TD&gt;1/03/2016&lt;/TD&gt;&lt;TD&gt;7/03/2016&lt;/TD&gt;&lt;TD&gt;Handler A&lt;/TD&gt;&lt;TD&gt;DONE&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Intake&lt;/TD&gt;&lt;TD&gt;8/03/2016&lt;/TD&gt;&lt;TD&gt;1/03/2016&lt;/TD&gt;&lt;TD&gt;22/03/2016&lt;/TD&gt;&lt;TD&gt;Handler B&lt;/TD&gt;&lt;TD&gt;DONE&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Intake&lt;/TD&gt;&lt;TD&gt;8/03/2016&lt;/TD&gt;&lt;TD&gt;1/03/2016&lt;/TD&gt;&lt;TD&gt;4/03/2016&lt;/TD&gt;&lt;TD&gt;Handler C&lt;/TD&gt;&lt;TD&gt;DONE&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Intake&lt;/TD&gt;&lt;TD&gt;8/03/2016&lt;/TD&gt;&lt;TD&gt;1/03/2016&lt;/TD&gt;&lt;TD&gt;9/03/2016&lt;/TD&gt;&lt;TD&gt;Handler D&lt;/TD&gt;&lt;TD&gt;DONE&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Intake&lt;/TD&gt;&lt;TD&gt;8/03/2016&lt;/TD&gt;&lt;TD&gt;1/03/2016&lt;/TD&gt;&lt;TD&gt;22/03/2016&lt;/TD&gt;&lt;TD&gt;Handler E&lt;/TD&gt;&lt;TD&gt;DONE&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Intake&lt;/TD&gt;&lt;TD&gt;8/03/2016&lt;/TD&gt;&lt;TD&gt;1/03/2016&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;Handler F&lt;/TD&gt;&lt;TD&gt;ACTIVE&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Intake&lt;/TD&gt;&lt;TD&gt;8/03/2016&lt;/TD&gt;&lt;TD&gt;1/03/2016&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;Handler G&lt;/TD&gt;&lt;TD&gt;ACTIVE&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Intake&lt;/TD&gt;&lt;TD&gt;8/03/2016&lt;/TD&gt;&lt;TD&gt;1/03/2016&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;Handler H&lt;/TD&gt;&lt;TD&gt;ACTIVE&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have to make a table in which I can show how many "intakes" an employee has closed and how many "intakes" an employee still has opened. In addition, they also want me to display how many of these tasks were closed after the deadline expired. (Obviously this part requires me to focus on task_state ACTIVE and DONE.)&amp;nbsp;I also have to add a final column that displays how many tasks have been CANCELLED.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Important note: Employees are able to adjust the sequence of tasks, which means that I cannot reply on sequence value 1. Instead I use "like '%intake%'". If the task is cancelled, the deadline, the start_date and the close_date are empty cells. If the task is still active, the close_date is an empty cell.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The result should look like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;task_handler&lt;/TD&gt;&lt;TD&gt;task_state&lt;/TD&gt;&lt;TD&gt;amount_of_tasks&lt;/TD&gt;&lt;TD&gt;expired&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Handler A&lt;/TD&gt;&lt;TD&gt;ACTIVE&lt;/TD&gt;&lt;TD&gt;4&lt;/TD&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Handler A&lt;/TD&gt;&lt;TD&gt;DONE&lt;/TD&gt;&lt;TD&gt;5&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Handler A&lt;/TD&gt;&lt;TD&gt;CANCELLED&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Handler B&lt;/TD&gt;&lt;TD&gt;ACTIVE&lt;/TD&gt;&lt;TD&gt;3&lt;/TD&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Handler B&lt;/TD&gt;&lt;TD&gt;DONE&lt;/TD&gt;&lt;TD&gt;9&lt;/TD&gt;&lt;TD&gt;5&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Handler B&lt;/TD&gt;&lt;TD&gt;CANCELLED&lt;/TD&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is the query I created so far:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;(Import Excel file into SAS library.)&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;STRONG&gt;PROC&lt;/STRONG&gt;&lt;/FONT&gt; &lt;STRONG&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;IMPORT&lt;/FONT&gt;&lt;/STRONG&gt; &lt;FONT color="#0000ff" face="Courier New" size="2"&gt;OUT&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;= ATROPOS.Tasks &lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;DATAFILE&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt;= &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="2"&gt;&lt;FONT color="#800080" face="Courier New" size="2"&gt;&lt;FONT color="#800080" face="Courier New" size="2"&gt;"random_location"&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;DBMS&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt;=XLS REPLACE;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;GETNAMES&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt;=YES;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;DATAROW&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt;=&lt;/FONT&gt;&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;2&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt;; &lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;GUESSINGROWS&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt;=&lt;/FONT&gt;&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;696430&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt;; &lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;STRONG&gt;RUN&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt;(Add a column called Expired, which contains close_date - deadline.)&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;STRONG&gt;PROC&lt;/STRONG&gt;&lt;/FONT&gt; &lt;STRONG&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;SQL&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;CREATE&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;TABLE&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt; Atropos.TasksEXP &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;AS&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;SELECT&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt; *, (close_date - deadline) &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;AS&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt; Expired&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;FROM&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt; ATROPOS.Tasks;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;STRONG&gt;QUIT&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;(Creating the table and adjusting Expired values. (Expired &amp;gt; 0 = Yes // Expired &amp;lt;= 0 = No))&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;STRONG&gt;PROC&lt;/STRONG&gt;&lt;/FONT&gt; &lt;STRONG&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;SQL&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;CREATE&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;TABLE&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt; ATROPOS.Startup &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;AS&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;SELECT&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt; task_handler, task_state, COUNT(*) &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;AS&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt; amount_of_tasks, Expired&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;FROM&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt; ATROPOS.Tasks&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;WHERE&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt; task_state &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;IN&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt; (&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="2"&gt;&lt;FONT color="#800080" face="Courier New" size="2"&gt;&lt;FONT color="#800080" face="Courier New" size="2"&gt;'ACTIVE'&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt;,&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="2"&gt;&lt;FONT color="#800080" face="Courier New" size="2"&gt;&lt;FONT color="#800080" face="Courier New" size="2"&gt;'DONE','CANCELLED'&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt;)&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;AND&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt; object_name &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;LIKE&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt; &lt;FONT color="#800080" face="Courier New" size="2"&gt;&lt;FONT color="#800080" face="Courier New" size="2"&gt;&lt;FONT color="#800080" face="Courier New" size="2"&gt;'%Intake%'&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#800080" face="Courier New" size="2"&gt;&lt;FONT color="#800080" face="Courier New" size="2"&gt;&lt;FONT color="#800080" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;AND&lt;/FONT&gt; &lt;FONT color="#ff0000"&gt;&lt;U&gt;IF (Expired &amp;gt; 0) THEN (Expired = 'Yes') ELSE (Expired = 'No')&lt;/U&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;GROUP&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;BY&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt; task_handler, task_state;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;STRONG&gt;QUIT&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am having issues getting the IF THEN ELSE statement to work. IF remains unrecognized in a black font, whereas THEN and ELSE are recognized in a blue font. I have tried different notations, even without using brackets, but nothing appears to be working. Secondly, I find it difficult to adjust the values in Expired, even if I were to use a data or update statement. Any ideas? I am guessing I am using a very devious method or was I on the right track here?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advance.&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 05 Apr 2016 11:47:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/IF-statement-is-not-recognized-black-font-whereas-THEN-and-ELSE/m-p/261328#M50824</guid>
      <dc:creator>Yves_Boonen</dc:creator>
      <dc:date>2016-04-05T11:47:02Z</dc:date>
    </item>
    <item>
      <title>Re: IF statement is not recognized (black font), whereas THEN and ELSE is recognized (blue font)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/IF-statement-is-not-recognized-black-font-whereas-THEN-and-ELSE/m-p/261331#M50825</link>
      <description>&lt;P&gt;I just noticed a huge problem too.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For every close_date cell that has no value, the Expired cell will be 0 - X (where X is the deadline). This way they will always result in a negative value and thus they will always appear as not expired although they could still be expired.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;One important note: the original Excel file also contains r_creation_date, which is the creation date of the task. As for the "intake" task, the deadline is always 7 days after the creation date. So maybe another approach is required?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For example:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If creation_date = 01/03/2016 then deadline = 08/03/2016.&lt;/P&gt;</description>
      <pubDate>Tue, 05 Apr 2016 11:52:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/IF-statement-is-not-recognized-black-font-whereas-THEN-and-ELSE/m-p/261331#M50825</guid>
      <dc:creator>Yves_Boonen</dc:creator>
      <dc:date>2016-04-05T11:52:44Z</dc:date>
    </item>
    <item>
      <title>Re: IF statement is not recognized (black font), whereas THEN and ELSE is recognized (blue font)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/IF-statement-is-not-recognized-black-font-whereas-THEN-and-ELSE/m-p/261332#M50826</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sort data = have;
by handler;
run;

data want;
set have;
by handler;
retain
  active
  done
  cancelled
  expired
  others
;
if first.handler
then do;
  active = 0;
  done = 0;
  cancelled = 0;
  expired = 0;
  others = 0;
end;
select task_state;
  when ('DONE') do;
    done + 1;
    if close_date &amp;gt; deadline then expired + 1;
  end;
  when ('CANCELLED') cancelled + 1;
  when ('ACTIVE') active + 1;
  otherwise others + 1;
end;
if last.handler then output;
keep handler active done cancelled expired others;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;You might have to use transpose to convert from wide to long format, if that is necessary. Or you could create a multiple output in the last.handler block.&lt;/P&gt;</description>
      <pubDate>Tue, 05 Apr 2016 11:56:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/IF-statement-is-not-recognized-black-font-whereas-THEN-and-ELSE/m-p/261332#M50826</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2016-04-05T11:56:28Z</dc:date>
    </item>
    <item>
      <title>Re: IF statement is not recognized (black font), whereas THEN and ELSE is recognized (blue font)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/IF-statement-is-not-recognized-black-font-whereas-THEN-and-ELSE/m-p/261333#M50827</link>
      <description>&lt;P&gt;Holy, that is a different way of thinking then I am used to.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;One question though:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What happens if the query processes a task that hasn't been closed yet and thus has no value in close_date? If you look at the first table I showed, you will see that the last three handlers have no close_date because the task is still active. However, in the deadline column you will see 08/03/2016 as deadline, so we know they are expired. (The handler didn't respect the deadline and even though the task is still active, the deadline is expired.)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;EDIT: Typo's.&lt;/P&gt;</description>
      <pubDate>Tue, 05 Apr 2016 12:09:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/IF-statement-is-not-recognized-black-font-whereas-THEN-and-ELSE/m-p/261333#M50827</guid>
      <dc:creator>Yves_Boonen</dc:creator>
      <dc:date>2016-04-05T12:09:02Z</dc:date>
    </item>
    <item>
      <title>Re: IF statement is not recognized (black font), whereas THEN and ELSE is recognized (blue font)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/IF-statement-is-not-recognized-black-font-whereas-THEN-and-ELSE/m-p/261336#M50829</link>
      <description>&lt;P&gt;Just expand the ACTIVE part:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;select task_state;
  when ('DONE') do;
    done + 1;
    if close_date &amp;gt; deadline then expired + 1;
  end;
  when ('ACTIVE') do;
    active + 1;
    if date() &amp;gt; deadline then expired + 1;
  end;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Instead of using the date() function for today's date, you could define a "current date" into a macro variable before the data step and use that.&lt;/P&gt;</description>
      <pubDate>Tue, 05 Apr 2016 12:14:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/IF-statement-is-not-recognized-black-font-whereas-THEN-and-ELSE/m-p/261336#M50829</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2016-04-05T12:14:19Z</dc:date>
    </item>
    <item>
      <title>Re: IF statement is not recognized (black font), whereas THEN and ELSE is recognized (blue font)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/IF-statement-is-not-recognized-black-font-whereas-THEN-and-ELSE/m-p/261338#M50830</link>
      <description>&lt;P&gt;If you look at the OP, you could say I use standard SQL in SAS or at least try to. What is the method you posted called? Is that the process code from SAS itself?&lt;/P&gt;</description>
      <pubDate>Tue, 05 Apr 2016 12:17:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/IF-statement-is-not-recognized-black-font-whereas-THEN-and-ELSE/m-p/261338#M50830</guid>
      <dc:creator>Yves_Boonen</dc:creator>
      <dc:date>2016-04-05T12:17:32Z</dc:date>
    </item>
    <item>
      <title>Re: IF statement is not recognized (black font), whereas THEN and ELSE is recognized (blue font)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/IF-statement-is-not-recognized-black-font-whereas-THEN-and-ELSE/m-p/261343#M50833</link>
      <description>&lt;P&gt;This is the data step language, the "mother tongue" of SAS, so to say. As I'm coming from procedural programming (BASIC, PASCAL, C) and also have some experience with DBASE programming, this suits me more than SQL.&lt;/P&gt;
&lt;P&gt;I'm quite sure that one of the SQL experts here could provide a solution with SQL.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The data step can do some things rather easily (and make it easy to read) that take complicated thinking in SQL. PROC SQL can also be very resource-consuming in certain scenarios involving joins of large datasets.&lt;/P&gt;</description>
      <pubDate>Tue, 05 Apr 2016 12:28:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/IF-statement-is-not-recognized-black-font-whereas-THEN-and-ELSE/m-p/261343#M50833</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2016-04-05T12:28:43Z</dc:date>
    </item>
    <item>
      <title>Re: IF statement is not recognized (black font), whereas THEN and ELSE is recognized (blue font)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/IF-statement-is-not-recognized-black-font-whereas-THEN-and-ELSE/m-p/261345#M50835</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;There is no such thing as an IF THEN construct in SQL, you would use a CASE WHEN construct in SQL. &amp;nbsp;I think you may be over complicating it. &amp;nbsp;Firstly, check your data coming in from that proc import, I can guarentee you that using proc import (which is guessing procedure) combined with Excel (which is a very poor choice for data transfer) will give you issues. &amp;nbsp;Are your date fields acutally dates, are they called that, so many things can go wrong. &amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Assuming you data is accurate, then something like (untested - post test data in form of datastep if you would like tested code):&lt;/P&gt;
&lt;PRE&gt;proc sql;
  create table WANT as
  select  A.TASK_HANDLER,  
          A.TASK_STATE,
          count(*) as AMOUNT_OF_TASKS,
          (select count(*) from ATROPOS.TASKS 
           where TASK_HANDLER=A.TASK_HANDLER and TAST_STATE=A.TASK_STATE and CLOSE_DATE - DEADLINE &amp;gt; 0) as EXPIRED
  from    ATROPOS.TASKS
  group by TASK_HANDLER,
           TASK_STATE;
quit;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 05 Apr 2016 12:31:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/IF-statement-is-not-recognized-black-font-whereas-THEN-and-ELSE/m-p/261345#M50835</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2016-04-05T12:31:40Z</dc:date>
    </item>
    <item>
      <title>Re: IF statement is not recognized (black font), whereas THEN and ELSE is recognized (blue font)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/IF-statement-is-not-recognized-black-font-whereas-THEN-and-ELSE/m-p/261360#M50846</link>
      <description>&lt;P&gt;I currently have no access to the Atropos database, so the only way is to request a specific unload in the form of an Excel file. Since the Atropos database is managed by another team, chances are very real that I will never get access (not even read access). But that's something I have been looking out for as well. When you use a PROC IMPORT, how can you properly define the format of a column's value? I have been reading up on the FORMAT = DATE8. and stuff, but I hardly ever get it to work. I figured out already that this command only works in SELECT during PROC SQL, but I am having difficulties to get this to work in a datastep.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For example&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;PROC IMPORT&lt;/P&gt;&lt;P&gt;OUT = TEST.DATE&lt;/P&gt;&lt;P&gt;DATAFILE = "C:\temp\test.xls"&lt;/P&gt;&lt;P&gt;DBMS = XLS REPLACE;&lt;/P&gt;&lt;P&gt;GETNAMES = YES;&lt;/P&gt;&lt;P&gt;DATAROW = 2;&lt;/P&gt;&lt;P&gt;FORMAT deadline = DATE8. start_date = DATE8. close_date = DATE8. r_creation_date = DATE8.;&lt;/P&gt;&lt;P&gt;RUN;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This doesn't work for me. Even if I try using '...', "...", DDMMYYYY8. or DDMMYYYY10., it simply does not accept the FORMAT. Or do I have to define the variables even though I said to GETNAMES? Or does that only work in a datastep?&lt;/P&gt;</description>
      <pubDate>Tue, 05 Apr 2016 12:51:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/IF-statement-is-not-recognized-black-font-whereas-THEN-and-ELSE/m-p/261360#M50846</guid>
      <dc:creator>Yves_Boonen</dc:creator>
      <dc:date>2016-04-05T12:51:30Z</dc:date>
    </item>
    <item>
      <title>Re: IF statement is not recognized (black font), whereas THEN and ELSE is recognized (blue font)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/IF-statement-is-not-recognized-black-font-whereas-THEN-and-ELSE/m-p/261365#M50848</link>
      <description>&lt;P&gt;Yes, you can't do that. &amp;nbsp;As I said, proc import is a guessing procedure - it looks at your file and tries to guess the best strcuture for the data based on some rows of data. &amp;nbsp;This is the principal reason why proc import would not be my choice of process. &amp;nbsp;At worst I would take the Excel file if that is all you can get, and save to CSV, then write a datastep import program where you can specify what each data element is, set formats informats etc. &amp;nbsp;E.g.&lt;/P&gt;
&lt;PRE&gt;data imported;
  infile "c:\your_csv.csv" dlm=",";
  length var1 $200 var_2 8 var_3 $50;
  format var_1 $200 var_2 3. var_3 $10.;
  informat ...;
  input var_1 $ var_2 var_3 $;
run;&lt;/PRE&gt;</description>
      <pubDate>Tue, 05 Apr 2016 13:04:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/IF-statement-is-not-recognized-black-font-whereas-THEN-and-ELSE/m-p/261365#M50848</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2016-04-05T13:04:09Z</dc:date>
    </item>
    <item>
      <title>Re: IF statement is not recognized (black font), whereas THEN and ELSE is recognized (blue font)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/IF-statement-is-not-recognized-black-font-whereas-THEN-and-ELSE/m-p/261366#M50849</link>
      <description>&lt;P&gt;FORMAT works in a data step, but PROC IMPORT is a helper procedure that looks at the data, makes more or less educated guesses about the strcuture and then creates and runs a data step from that. Only 4 statements are valid within PROC IMPORT: DLM=, DATAROW=, GUESSINGROWS=, GETNAMES=.&lt;/P&gt;
&lt;P&gt;To force formats, one can take the data step that IMPORT creates from the log and modify that.&lt;/P&gt;</description>
      <pubDate>Tue, 05 Apr 2016 13:07:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/IF-statement-is-not-recognized-black-font-whereas-THEN-and-ELSE/m-p/261366#M50849</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2016-04-05T13:07:17Z</dc:date>
    </item>
    <item>
      <title>Re: IF statement is not recognized (black font), whereas THEN and ELSE is recognized (blue font)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/IF-statement-is-not-recognized-black-font-whereas-THEN-and-ELSE/m-p/261379#M50857</link>
      <description>&lt;P&gt;I managed to get rid of some errors, but there are some I simply cannot get rid of.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The code:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;PROC SORT IN=ATROPOS.Tasks OUT=ATROPOS.Tasks;
BY task_handler;
RUN;

DATA ATROPOS.Intake;
SET ATROPOS.Tasks;
BY task_handler;
RETAIN
  Active
  Done
  Cancelled
  Expired
  Others;

IF first.task_handler
THEN DO;
  Active=0;
  Done=0;
  Cancelled=0;
  Expired=0;
  Others=0;
END;

SELECT (task_state);
  WHEN ('DONE') DO;
    Done+1;
    IF close_date &amp;gt; deadline THEN Expired+1;
  END;

  WHEN ('CANCELLED') Cancelled+1;
  END;

  WHEN ('ACTIVE') DO;
    Active+1;
    IF date() &amp;gt; deadline THEN Expired+1;
  END;

  OTHERWISE Others+1;
  END;

IF last.task_handler THEN OUTPUT;
KEEP task_handler Active Done Cancelled Expired Others;
RUN;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The log:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;522  PROC SORT IN=ATROPOS.Tasks OUT=ATROPOS.Tasks;
523  BY task_handler;
524  RUN;

NOTE: Input data set is already sorted; it has been copied to the output data set.
NOTE: There were 15180 observations read from the data set ATROPOS.TASKS.
NOTE: The data set ATROPOS.TASKS has 15180 observations and 10 variables.
NOTE: PROCEDURE SORT used (Total process time):
      real time           0.01 seconds
      cpu time            0.00 seconds


525
526  DATA ATROPOS.Intake;
527  SET ATROPOS.Tasks;
528  BY task_handler;
529  RETAIN
530    Active
531    Done
532    Cancelled
533    Expired
534    Others;
535
536  IF first.task_handler
537  THEN DO;
538    Active=0;
539    Done=0;
540    Cancelled=0;
541    Expired=0;
542    Others=0;
543  END;
544
545  SELECT (task_state);
546    WHEN ('DONE') DO;
547      Done+1;
548      IF close_date &amp;gt; deadline THEN Expired+1;
549    END;
550
551    WHEN ('CANCELLED') Cancelled+1;
552    END;
553
554    WHEN ('ACTIVE') DO;
       ----          -
       161           161
ERROR 161-185: No matching DO/SELECT statement.

555      Active+1;
556      IF date() &amp;gt; deadline THEN Expired+1;
557    END;
558
559    OTHERWISE Others+1;
       ---------
       161
560    END;
       ---
       161
ERROR 161-185: No matching DO/SELECT statement.

561
562  IF last.task_handler THEN OUTPUT;
563  KEEP task_handler Active Done Cancelled Expired Others;
564  RUN;

NOTE: The SAS System stopped processing this step because of errors.
WARNING: The data set ATROPOS.INTAKE may be incomplete.  When this step was stopped there were 0
         observations and 6 variables.
WARNING: Data set ATROPOS.INTAKE was not replaced because this step was stopped.
NOTE: DATA statement used (Total process time):
      real time           0.06 seconds
      cpu time            0.06 seconds


&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Both "No matching DO/SELECT statement" errors are weird to me. I cross checked with the first "WHEN ('DONE') DO;" statement and the ones that come after it have the exact same syntax. So why are the last two reporting errors and the first isn't? Do I have to repeat the "SELECT (task_state);" for every "WHEN X DO;" statement?&lt;/P&gt;</description>
      <pubDate>Tue, 05 Apr 2016 13:31:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/IF-statement-is-not-recognized-black-font-whereas-THEN-and-ELSE/m-p/261379#M50857</guid>
      <dc:creator>Yves_Boonen</dc:creator>
      <dc:date>2016-04-05T13:31:53Z</dc:date>
    </item>
    <item>
      <title>Re: IF statement is not recognized (black font), whereas THEN and ELSE is recognized (blue font)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/IF-statement-is-not-recognized-black-font-whereas-THEN-and-ELSE/m-p/261380#M50858</link>
      <description>&lt;P&gt;I forgot the date macro, but I'll work on that now. I am not certain where I have to define that exactly. In between two datasteps in a new and indipendent datastep?&lt;/P&gt;</description>
      <pubDate>Tue, 05 Apr 2016 13:34:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/IF-statement-is-not-recognized-black-font-whereas-THEN-and-ELSE/m-p/261380#M50858</guid>
      <dc:creator>Yves_Boonen</dc:creator>
      <dc:date>2016-04-05T13:34:22Z</dc:date>
    </item>
    <item>
      <title>Re: IF statement is not recognized (black font), whereas THEN and ELSE is recognized (blue font)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/IF-statement-is-not-recognized-black-font-whereas-THEN-and-ELSE/m-p/261382#M50860</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;DATA ATROPOS.Intake;
SET ATROPOS.Tasks;
BY task_handler;
RETAIN
  Active
  Done
  Cancelled
  Expired
  Others;

IF first.task_handler
THEN DO;
  Active=0;
  Done=0;
  Cancelled=0;
  Expired=0;
  Others=0;
END;

SELECT (task_state);
  WHEN ('DONE') DO;
    Done+1;
    IF close_date &amp;gt; deadline THEN Expired+1;
  END;

  WHEN ('CANCELLED') Cancelled+1;
  *END; * this END has no preceding DO!;

  WHEN ('ACTIVE') DO;
    Active+1;
    IF date() &amp;gt; deadline THEN Expired+1;
  END;

  OTHERWISE Others+1;
END; * put this END in column 1, as it closes the SELECT;

IF last.task_handler THEN OUTPUT;
KEEP task_handler Active Done Cancelled Expired Others;
RUN;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;See my inline comments.&lt;/P&gt;</description>
      <pubDate>Tue, 05 Apr 2016 13:36:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/IF-statement-is-not-recognized-black-font-whereas-THEN-and-ELSE/m-p/261382#M50860</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2016-04-05T13:36:57Z</dc:date>
    </item>
    <item>
      <title>Re: IF statement is not recognized (black font), whereas THEN and ELSE is recognized (blue font)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/IF-statement-is-not-recognized-black-font-whereas-THEN-and-ELSE/m-p/261384#M50862</link>
      <description>&lt;P&gt;This part:&lt;/P&gt;
&lt;PRE class=" language-sas"&gt;&lt;CODE class="  language-sas"&gt;&lt;SPAN class="token number"&gt;550&lt;/SPAN&gt;
&lt;SPAN class="token number"&gt;551&lt;/SPAN&gt;    WHEN &lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;&lt;SPAN class="token string"&gt;'CANCELLED'&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt; Cancelled&lt;SPAN class="token operator"&gt;+&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;1&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
&lt;SPAN class="token number"&gt;552&lt;/SPAN&gt;    END&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Ends the select statement as the when has no do, thus the end; ends the select. &amp;nbsp;The other errors follow on from this problem, i.e. fix this, and the other should go away. &amp;nbsp;I.e. remove this END:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;As another point, its not a good idea to code all in caps, or mixed case, and consistent indenting will highlight the incorrect part in a fair few examples:&lt;/P&gt;
&lt;PRE&gt;proc sort in=atropos.tasks out=atropos.tasks;
  by task_handler;
run;

data atropos.intake;
  set atropos.tasks;
  by task_handler;
  retain active done cancelled expired others;
  if first.task_handler then do;
    active=0;
    done=0;
    cancelled=0;
    expired=0;
    others=0;
  end;
  select (task_state);
    when ('DONE') do;
      done+1;
      if close_date &amp;gt; deadline then expired+1;
    end;
    when ('CANCELLED') cancelled+1;
    when ('ACTIVE') do;
      active+1;
      if date() &amp;gt; deadline then expired+1;
    end;
    otherwise others+1;
  end;
  if last.task_handler then output;
  keep task_handler active done cancelled expired others;
run;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 05 Apr 2016 13:39:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/IF-statement-is-not-recognized-black-font-whereas-THEN-and-ELSE/m-p/261384#M50862</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2016-04-05T13:39:13Z</dc:date>
    </item>
    <item>
      <title>Re: IF statement is not recognized (black font), whereas THEN and ELSE is recognized (blue font)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/IF-statement-is-not-recognized-black-font-whereas-THEN-and-ELSE/m-p/261390#M50867</link>
      <description>&lt;P&gt;Can I borrow your brains from time to time please?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;img id="smileyhappy" class="emoticon emoticon-smileyhappy" src="https://communities.sas.com/i/smilies/16x16_smiley-happy.png" alt="Smiley Happy" title="Smiley Happy" /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In all honesty, this has been a very educational experience. In the division I am working at, SAS experience and knowledge is non existent. It is my assignment to start working on it and make sure that it can be used to its full potential. Since no one here can help me, I try to do a lot on my own. It's very complicated matter,&amp;nbsp;so it is very nice to see a community like this one.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Much appreciated!&lt;/P&gt;</description>
      <pubDate>Tue, 05 Apr 2016 13:45:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/IF-statement-is-not-recognized-black-font-whereas-THEN-and-ELSE/m-p/261390#M50867</guid>
      <dc:creator>Yves_Boonen</dc:creator>
      <dc:date>2016-04-05T13:45:30Z</dc:date>
    </item>
    <item>
      <title>Re: IF statement is not recognized (black font), whereas THEN and ELSE is recognized (blue font)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/IF-statement-is-not-recognized-black-font-whereas-THEN-and-ELSE/m-p/261513#M50913</link>
      <description>&lt;P&gt;I recommend contacting your management about SAS training. There are a variety of on-line training types, some mediated and some self-paced as well as discounts for multiple sessions. Also the SAS book store has lots of publications with details and implementations of different SAS products and procedures.&lt;/P&gt;</description>
      <pubDate>Tue, 05 Apr 2016 20:32:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/IF-statement-is-not-recognized-black-font-whereas-THEN-and-ELSE/m-p/261513#M50913</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2016-04-05T20:32:52Z</dc:date>
    </item>
  </channel>
</rss>

