Date: Fri, 7 May 2004 12:53:46 -0400
Reply-To: Howard Schreier <Howard_Schreier@ITA.DOC.GOV>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Howard Schreier <Howard_Schreier@ITA.DOC.GOV>
Subject: Re: Using IF statement with : "colon" instead of SUBSTR
It may effectively mean "begins with" for the data in question, but it
really is an instruction to perform the comparison operation by truncating
the longer operand to the length of the shorter, if necessary. Without the
colon, operands of unequal length are compared by padding the shorter to
the length of the longer.
In Laurel's dataset, VA_PRODU undoubtedly has a length sufficient to
accommodate any of the drug names. But technically this is not necessary.
sig = 'PRN';
va_produ = 'A';
FLAGprn=(va_produ in:('ALPRAZOLAM', 'CHLORDIAZEPOXIDE', 'CLONAZEPAM',
'CLORAZEPATE', 'DIAZEPAM', 'LORAZEPAM', 'OXAZEPAM', 'PRAZEPAM',
The log shows:
That's because "ALPRAZOLAM" begins with "A".
The colon can also be used with the various inequality comparison operators.
It is documented in the section on expressions and operators. See
Kevin viewed it as a feature of the IF statement, which it is not. That's
the nature of SAS and its documentation. It's often hard to find things
unless you know how the pieces fit together.
On Fri, 7 May 2004 08:23:08 -0500, Laurel Copeland
>The colon in this context means "begins with" and can also be used with
>DATA ck2; SET rxadh;
> FLAGprn=(va_produ in:('ALPRAZOLAM', 'CHLORDIAZEPOXIDE', 'CLONAZEPAM',
>'CLORAZEPATE', 'DIAZEPAM', 'LORAZEPAM', 'OXAZEPAM', 'PRAZEPAM',
> AND index(sig,'PRN'));
>From: Kevin Clark [mailto:KClark@CMS.HHS.GOV]
>Sent: Friday, May 07, 2004 8:49 AM
>Subject: Using IF statement with : "colon" instead of SUBSTR
>I recall some code years ago that allowed me to make a partial compare on a
>literal string by using a ':' colon somewhere in the IF statement.
>Such as If Day = :'mon' (where day is an eight character
>so only the first three characters are compared.
>Any help is welcome.