<?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 IF-THEN Loop in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/IF-THEN-Loop/m-p/49977#M13566</link>
    <description>Hi,&lt;BR /&gt;
&lt;BR /&gt;
I use the code as -&lt;BR /&gt;
&lt;BR /&gt;
data Week; &lt;BR /&gt;
	set Day;&lt;BR /&gt;
		IF ("1/01/2001"&amp;lt;=Date&amp;lt;="7/01/2001") then 'Week'= 'Week1';&lt;BR /&gt;
			IF ("8/01/2001"&amp;lt;=Date&amp;lt;="14/01/2001") then 'Week' = 'Week2';&lt;BR /&gt;
				IF ("15/01/2001"&amp;lt;=Date&amp;lt;="21/01/2001") then 'Week' = 'Week3';&lt;BR /&gt;
		ELSE IF ("22/01/2001"&amp;lt;=Date&amp;lt;="28/01/2001")then 'Week' = 'Week4';&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
The date is character in the code .&lt;BR /&gt;
&lt;BR /&gt;
LOG ERROR 180-322: Statement is not valid or it is used out of proper order.&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Kindly suggest where am wrong or any articles that deal with this coding...&lt;BR /&gt;
&lt;BR /&gt;
Regards,&lt;BR /&gt;
Mark</description>
    <pubDate>Thu, 15 Jul 2010 04:09:43 GMT</pubDate>
    <dc:creator>deleted_user</dc:creator>
    <dc:date>2010-07-15T04:09:43Z</dc:date>
    <item>
      <title>IF-THEN Loop</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/IF-THEN-Loop/m-p/49977#M13566</link>
      <description>Hi,&lt;BR /&gt;
&lt;BR /&gt;
I use the code as -&lt;BR /&gt;
&lt;BR /&gt;
data Week; &lt;BR /&gt;
	set Day;&lt;BR /&gt;
		IF ("1/01/2001"&amp;lt;=Date&amp;lt;="7/01/2001") then 'Week'= 'Week1';&lt;BR /&gt;
			IF ("8/01/2001"&amp;lt;=Date&amp;lt;="14/01/2001") then 'Week' = 'Week2';&lt;BR /&gt;
				IF ("15/01/2001"&amp;lt;=Date&amp;lt;="21/01/2001") then 'Week' = 'Week3';&lt;BR /&gt;
		ELSE IF ("22/01/2001"&amp;lt;=Date&amp;lt;="28/01/2001")then 'Week' = 'Week4';&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
The date is character in the code .&lt;BR /&gt;
&lt;BR /&gt;
LOG ERROR 180-322: Statement is not valid or it is used out of proper order.&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Kindly suggest where am wrong or any articles that deal with this coding...&lt;BR /&gt;
&lt;BR /&gt;
Regards,&lt;BR /&gt;
Mark</description>
      <pubDate>Thu, 15 Jul 2010 04:09:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/IF-THEN-Loop/m-p/49977#M13566</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2010-07-15T04:09:43Z</dc:date>
    </item>
    <item>
      <title>Re: IF-THEN Loop</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/IF-THEN-Loop/m-p/49978#M13567</link>
      <description>Hi:&lt;BR /&gt;
  As I explained in a previous post, when you have syntax constructions like &amp;lt; or &amp;gt; or &amp;lt;= , then you must follow the guidelines laid out in the forum posting to which you were previously referred (on July 12 and shown below) &lt;BR /&gt;
&lt;BR /&gt;
In that forum posting, it explains that you need to REPLACE &amp;lt; with &amp;amp;lt; in your code or &amp;lt;= with &amp;amp;lt;= or with LE.&lt;BR /&gt;
       &lt;BR /&gt;
  Otherwise, your code will get truncated and no one will be able to help you. And, yes, it is sort of a pain to do this extra bit of work to post your code, but if you want folks to help you, it is a courtesy to pay attention to what people post and to show that you understand what they are trying to tell you.&lt;BR /&gt;
    &lt;BR /&gt;
  For example, you might have wanted to show us something like this:&lt;BR /&gt;
[pre]&lt;BR /&gt;
 data Week; &lt;BR /&gt;
 	set Day;&lt;BR /&gt;
 IF ("1/01/2001" &amp;lt;= Date &amp;lt;= "7/01/2001") then Week= 'Week1';&lt;BR /&gt;
...more code...&lt;BR /&gt;
[/pre]&lt;BR /&gt;
        &lt;BR /&gt;
but if you had &amp;lt;= in your code the &amp;lt; would have messed up the forum posting. (And the reason it didn't mess up my code is that I followed the suggestion in the forum topic on preventing special characters from truncating your posting.)&lt;BR /&gt;
&lt;BR /&gt;
If, for example, you tried an IF statement like this, there is an automatic problem if DATE is a SAS date variable. SAS expects any comparisons to a DATE variable to be done either as the numeric value or as the DATE7 or DATE9 version of the date like this (showing an equality test...not a "between" test):&lt;BR /&gt;
    &lt;BR /&gt;
[pre]&lt;BR /&gt;
IF DATE = '01JAN2001'd then ...;&lt;BR /&gt;
or&lt;BR /&gt;
IF DATE = 14976 then ....;&lt;BR /&gt;
[/pre]&lt;BR /&gt;
&lt;BR /&gt;
Previous forum postings on the subject of date and date/time variables:&lt;BR /&gt;
&lt;A href="http://support.sas.com/forums/message.jspa?messageID=39424#39424" target="_blank"&gt;http://support.sas.com/forums/message.jspa?messageID=39424#39424&lt;/A&gt;&lt;BR /&gt;
&lt;A href="http://support.sas.com/forums/thread.jspa?messageID=33006胮" target="_blank"&gt;http://support.sas.com/forums/thread.jspa?messageID=33006胮&lt;/A&gt;&lt;BR /&gt;
&lt;BR /&gt;
Previous forum postings on how to post code with special characters such as &amp;lt; and &amp;gt;&lt;BR /&gt;
&lt;A href="http://support.sas.com/forums/thread.jspa?messageID=27609" target="_blank"&gt;http://support.sas.com/forums/thread.jspa?messageID=27609&lt;/A&gt; (someone already sent you this posting to read on July 12)&lt;BR /&gt;
&lt;A href="http://support.sas.com/forums/message.jspa?messageID=39361#39361" target="_blank"&gt;http://support.sas.com/forums/message.jspa?messageID=39361#39361&lt;/A&gt;&lt;BR /&gt;
 &lt;BR /&gt;
cynthia</description>
      <pubDate>Thu, 15 Jul 2010 17:58:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/IF-THEN-Loop/m-p/49978#M13567</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2010-07-15T17:58:33Z</dc:date>
    </item>
  </channel>
</rss>

