Date: Tue, 16 Mar 2010 17:03:24 -0600
Reply-To: Joe Matise <snoopy369@GMAIL.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Joe Matise <snoopy369@GMAIL.COM>
Subject: Re: Problems with sorting an array with hash objects
In-Reply-To: <100FCDB28E638D4B903CB7D2056E43C704590358@USFCH-MAIL1.lewin.com>
Content-Type: text/plain; charset=ISO-8859-1
Any particular reason you don't use CALL SORTN/SORTC? They should be
available in 9.1.3 I believe even though undocumented until 9.2.
-Joe
On Tue, Mar 16, 2010 at 3:48 PM, Kirby, Ted <ted.kirby@lewin.com> wrote:
> I am attempting to "hijack" the code from page 10 of Dorfman and
> Vyverman's excellent SAS Global Forum 2009 paper "The SAS(r) Hash Object
> in Action" and am getting system errors that I do not understand.
>
>
>
> What I am trying to do is sort and remove duplicate diagnosis codes from
> observations that may have up to 19 ICD-9 codes. However, when I
> process the Procedure codes (SecProc01-SecProc11) I will want to sort
> the codes, but allow duplicates, so I was going to change the "nodupkey"
> parameter to 0 and reprocess the code.
>
>
>
> However, I cannot get past the first run with the diagnosis codes.
>
>
>
> Here is the code (with thanks to Dorfman and Vyverman):
>
> data EpisodePreGroup;
>
>
>
> ** set sort parameters ;
>
> seq = 'A' ; * A = ascending, D = descending ;
>
> nodupkey = 1 ; * 0 = duplicates allowed, 1 = duplicates not allowed ;
>
>
>
> declare hash _Dxs (ordered: seq);
>
> declare hiter _DXsi ('_Dxs');
>
> _Dxs.defineKey('_k', '_n');
>
> _Dxs.defineData('_k');
>
> _Dxs.defineDone();
>
>
>
> set tempData;
>
>
>
> array SecDxs{*} SecDx01-SecDx19;
>
> array SecProcs{*} SecProc01-SecProc11;
>
>
>
> do i=1 to dim(secDxs);
>
> if SecDxs{i}=PrincDx then SecDxs{i}=" ";
>
> end;
>
>
>
> ** load composite (_k _n) key on the table ;
>
> ** if duplicates to be retained, set 0 <- _n ;
>
> do _j = lbound (SecDxs) to hbound (SecDxs) ;
>
> _n = _j * ^ nodupkey ;
>
> _k = SecDxs [_j] ;
>
> _Dxs.replace() ;
>
> end ;
>
> ** use iterator Dxsi to reload array from Dxs table, now in order ;
>
> _n = lbound (SecDxs) - 1 ;
>
> do _rc = _Dxsi.first() by 0 while ( _rc = 0 ) ;
>
> _n = _n + 1 ;
>
> SecDxs [_n] = _k ;
>
> _rc = _Dxsi.next() ;
>
> end ;
>
> _q = _n ;
>
> ** fill array tail with missing values if duplicates are delete ;
>
> do _n = _q + 1 to hbound (SecDxs) ;
>
> SecDxs [_n] = " " ;
>
> end ;
>
> drop _: ; * drop auxiliary variables ;
>
> run;
>
>
>
> Here is the error messages:
>
>
>
> ERROR: Read Access Violation In Task [ DATASTEP )
>
> Exception occurred at (5DD11138)
>
> Task Traceback
>
> Address Frame (DBGHELP API Version 4.0 rev 5)
>
> 5DD11138 02EFFE28 0001:00000138 tkeai.dll
>
> 64391457 02EFFE5C sasdai:mcn_main+0x457
>
> 6725B296 02EFFEC0 sasdsx:mcn_main+0x2A296
>
> 01557DB5 02EFFF04 sashost:Main+0xB1125
>
> 6723158A 02EFFF44 sasdsx:mcn_main+0x58A
>
> 673115BC 02EFFF88 sasds:mcn_main+0x5BC
>
> 014B2B02 02EFFFA0 sashost:Main+0xBE72
>
> 014B6C20 02EFFFB4 sashost:Main+0xFF90
>
> 7C80B729 02EFFFEC kernel32:GetModuleFileNameA+0x1BA
>
>
>
> I have tried moving the hash code after the set and array statements,
> but get the same results.
>
>
>
>
>
>
> ************* 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.
>
>
|