Date: Tue, 12 Jun 2012 15:31:55 +0000
Reply-To: "Nordlund, Dan (DSHS/RDA)" <NordlDJ@DSHS.WA.GOV>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: "Nordlund, Dan (DSHS/RDA)" <NordlDJ@DSHS.WA.GOV>
Subject: Re: In() Function
In-Reply-To: <CAM+YpE_7yWYUuLwoNj-1WJ78tM+7j-TrrHRHnWs9ptAiLVtmvw@mail.gmail.com>
Content-Type: text/plain; charset=utf-8
> -----Original Message-----
> From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of
> Joe Matise
> Sent: Monday, June 11, 2012 6:34 PM
> To: SAS-L@LISTSERV.UGA.EDU
> Subject: Re: In() Function
>
> I interpreted Mike's rules to be:
> *Works like WHICHN function, except that all arguments are truncated to
> the
> length of the first argument. This differs from WHICHN, which makes
> each
> comparison exactly (so 'IN' is not equal to 'INDEX'). IN('IN','INDEX')
> would return TRUE.
>
> So whereas WHICHN will process each comparison as
> IN1 = IN2
> IN() processes each comparison as
> IN1 =: IN2
>
<<<snip>>>
Joe,
The IN() function only "kind of works" like
IN1 =: IN2
The "=:" operator compares IN1 and IN2 up to the length of the shorter of the two strings, regardless of whether the shorter string is IN1 or IN2.
The IN() function appears to return FALSE if IN2 is shorter than IN1.
data _null_;
in1 = 'abc';
in2 = 'ab';
compare1 = in(in1,in2);
compare2 = in1 =: in2;
put compare1= compare2=;
run;
Hope this is helpful,
Dan
Daniel J. Nordlund
Washington State Department of Social and Health Services
Planning, Performance, and Accountability
Research and Data Analysis Division
Olympia, WA 98504-5204
|