Date: Tue, 28 Nov 2006 16:30:44 -0800
Reply-To: "Choate, Paul@DDS" <pchoate@DDS.CA.GOV>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: "Choate, Paul@DDS" <pchoate@DDS.CA.GOV>
Subject: Re: Date range condition (syntax confusion)
In-Reply-To: <20061128211506.48695.qmail@web34101.mail.mud.yahoo.com>
Content-Type: text/plain; charset="us-ascii"
Hi Irin - This is a SAS shorthand called the "implied AND":
IF <value> <comparison> <variable> <comparison> <value>;
Is reconfigured by SAS as
IF <value> <comparison> <variable> AND <variable> <comparison> <value>;
<<<<<<<<<<<<<<<<SAS Operators in Expressions>>>>>>>>>>>>>>>>>>
The AND Operator
...
Two comparisons with a common variable linked by AND can be condensed
with an implied AND. For example, the following two subsetting IF
statements produce the same result:
if 16<=age and age<=65;
if 16<=age<=65;
<<<<<<<<<<<<<<<<SAS Operators in Expressions>>>>>>>>>>>>>>>>>>
It is not evaluated as "if ((16<=age)<=65);" which otherwise would be
the result under the standard order of operations.
Note that this can be extended, quickly leading to a migraine:
True:
data;
x=-3;
y=-2;
if -4<x<y<-1;
run;
False:
data;
x=-3;
y=-2;
if (((-4<x)<y)<-1);
run;
If you are going beyond a single comparison it is likely best to use
parentheses to explicitly state your intended order of operations.
hth
Paul Choate
DDS Data Extraction
(916) 654-2160
-----Original Message-----
From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of
Irin later
Sent: Tuesday, November 28, 2006 1:15 PM
To: SAS-L@LISTSERV.UGA.EDU
Subject: Date range condition (syntax confusion)
I look at somebody's code and got confused.
Let's say that just the extract of active members was needed...
The following looks for me like the condition sets that members' term
date is between the very beginning and the very end of the month.
However Data Active in the code and other comments contradict my
assumption....
/***Isolate Actives october lines***/
Data active;
Set all
If '01OCT06'D <= cov_term_dt<='31OCT06'd;
Run;
Looking at the code I would assume that the above statement sets the
same as the following:
cov_term_dt >='01OCT06'D and cov_term_dt<='31OCT06'd;
In that case it would mean that members within the month were
terminated.
Does this initial syntax really means that cov_term_dt should be
outside of the date_range?
Thank you!
Irin
---------------------------------
Access over 1 million songs - Yahoo! Music Unlimited.