Date: Tue, 4 Sep 2007 13:10:07 -0400
Reply-To: Muthia Kachirayan <muthia.kachirayan@GMAIL.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Muthia Kachirayan <muthia.kachirayan@GMAIL.COM>
Subject: Re: hash add method
In-Reply-To: <%FeDi.77$6V1.156806@news.sisna.com>
Content-Type: text/plain; charset=ISO-8859-1
On 9/4/07, Richard A. DeVenezia <rdevenezia@wildblue.net> wrote:
>
> Oft times a hash is simply used to test if a value is in some set.
>
> What I find peculiar is that when a hash has only keys, the .ADD method
> cannot be used if the key: tag is utilized!
>
> data _null_;
>
> declare hash S();
> S.defineKey('element');
> S.defineDone();
>
> element = 'a';
> S.add();
> element = 'b';
> S.add();
>
> if S.find(key:'c') ne 0 then
> put "'c' is not in S";
>
> * key: tag causes an error !;
> S.add(key:'c');
>
> if S.find(key:'c') eq 0 then
> put "'c' is in S";
>
> stop;
> run;
>
> Does such an error seem reasonable ? Not to me :(
>
> Another interesting quirk, when a hash has only keys, the OUTPUT method
> writes out the key values. When a hash hash keys and data, only the data
> is
> written out.
>
> --
> Richard A. DeVenezia
Richard,
.add() is not liked but it likes ...
if S.find(key:'c') ne 0 then S.replace();
There is no error message !!
Regards,
Muthia Kachirayan
|