IF ("1/01/2001"<=Date<="7/01/2001") then 'Week'= 'Week1';
IF ("8/01/2001"<=Date<="14/01/2001") then 'Week' = 'Week2';
IF ("15/01/2001"<=Date<="21/01/2001") then 'Week' = 'Week3';
ELSE IF ("22/01/2001"<=Date<="28/01/2001")then 'Week' = 'Week4';
The date is character in the code .
LOG ERROR 180-322: Statement is not valid or it is used out of proper order.
Kindly suggest where am wrong or any articles that deal with this coding...
As I explained in a previous post, when you have syntax constructions like < or > or <= , then you must follow the guidelines laid out in the forum posting to which you were previously referred (on July 12 and shown below)
In that forum posting, it explains that you need to REPLACE < with < in your code or <= with <= or with LE.
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.
For example, you might have wanted to show us something like this:
IF ("1/01/2001" <= Date <= "7/01/2001") then Week= 'Week1';
but if you had <= in your code the < 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.)
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):
IF DATE = '01JAN2001'd then ...;
IF DATE = 14976 then ....;