Date: Wed, 13 Apr 2011 07:53:55 -0500
Reply-To: Joe Matise <snoopy369@GMAIL.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Joe Matise <snoopy369@GMAIL.COM>
Subject: Re: SELECT group and IF-THEN/ELSE statements
In-Reply-To: <B90B817A9BBB904AAAD7EC321C01596722423D@USFCH-MAIL1.lewin.com>
Content-Type: text/plain; charset=ISO-8859-1
I'll add to that, that you should use a better method (like FORMAT or HASH)
if you're going to have a long list of single qualifiers... SELECT is still
relatively inefficient for processing things like that (Such as the example
below). I mostly find SELECT useful for nonequalities (which it's actually
not as good at as I'd like).
-Joe
On Wed, Apr 13, 2011 at 6:30 AM, Kirby, Ted <ted.kirby@lewin.com> wrote:
> If you have relatively few conditions to check then you would use IF
> THEN statements as in:
>
> If sex=1 then gender="Male";
> else if sex=2 then gender="Female";
>
> However, if you have a larger number of conditions then you would use a
> SELECT group as in:
>
> select(dischargecode);
> when("01") dischgdisp="Home";
> when("02") dischgdisp="Short-term Hospital";
> when("03") dischgdisp="SNF";
> when("04") dischgdisp="ICF";
> when("05") dischgdisp="Cancer Center";
>
> .
> .
> .
>
> when("70") dischgdisp="Other";
> otherwise dischgdisp="Error";
> end;
>
> As you can see it would be a pain to have type IF-THEN-ELSE statements
> for the latter case.
>
> HTH
>
> kwselect kwifthenelse
> -----Original Message-----
> From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of
> Seung-min Baek
> Sent: Wednesday, April 13, 2011 5:11 AM
> To: SAS-L@LISTSERV.UGA.EDU
> Subject: SELECT group and IF-THEN/ELSE statements
>
> Hello,
> Now, I have the question.
>
> * IF-THEN / ELSE of SAS9.2 :
> http://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/vi
> ewer
> .htm#a000202239.htm
> Use a SELECT group rather than a series of IF-THEN statements when you
> have a long series of mutually exclusive conditions.
>
> * SELECT of SAS9.2
> http://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/vi
> ewer
> .htm#a000201966.htm
> Use IF-THEN/ELSE statements for programs with few statements.
>
> I want to know the illustration(Reason) and then difference of the two
> sentence.
>
> I want to know the description and example.
>
> Thank you!!
>
>
>
>
>
> [reference]
>
> http://support.sas.com/kb/10/197.html
>
> Problem Note 10197: Documentation incorrect about differences with
> SELECT group and IF-THEN/ELSE statements
>
> The SAS Language Reference: Dictionary, Version 8 incorrectly states:
> When you have a long series of mutually exclusive
> conditions, using a SELECT group is more efficient than
> using a series of IF-THEN statements because CPU time is
> reduced.
>
> The CPU time is equivalent as long as the conditions are put in the same
> order with each statement.
>
> The documentation is corrected beginning in SAS 9.1.
> ************* IMPORTANT - PLEASE READ ********************
>
> This e-mail, including attachments, may include confidential and/or
> proprietary information,
> and may be used only by the person or entity to which it is addressed. If
> the reader of this
> e-mail is not the intended recipient or his or her authorized agent, the
> reader is hereby
> notified that any dissemination, distribution or copying of this e-mail is
> prohibited. If you
> have received this e-mail in error, please notify the sender by replying to
> this message
> and delete this e-mail immediately.
>
>
|