LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous messageNext messagePrevious in topicNext in topicPrevious by same authorNext by same authorPrevious page (March 2010, week 3)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Tue, 16 Mar 2010 18:57:29 -0400
Reply-To:     "Kirby, Ted" <ted.kirby@LEWIN.COM>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         "Kirby, Ted" <ted.kirby@LEWIN.COM>
Subject:      Re: Problems with sorting an array with hash objects
Comments: To: Muthia Kachirayan <muthia.kachirayan@GMAIL.COM>
In-Reply-To:  A<2fc7f3341003161526m151e11a5s2cd49bed1d5f8148@mail.gmail.com>
Content-Type: text/plain; charset="us-ascii"

PROC SORT is used to sort observations; I want to sort variables within an observation, so it would not work for me without a double execution of PROC TRANSPOSE. I was hoping that hash sorting of an array would do away with the PROC TRANSPOSEs.

One thing I forgot to mention in my last post is that if a Secondary Diagnosis is the same code as the Principal Diagnosis, then I want it deleted. That was the purpose of:

do i=1 to dim(secDxs); if SecDxs{i}=PrincDx then SecDxs{i}=" "; end;

in the original code.

Here is an illustrative example (limited to 8 Secondary Diagnoses due to text editor limitations). If the original records were:

Patid PriDx SecDx1 SecDx2 SecDx3 SecDx4 SecDx5 SecDx6 SecDx7 SecDx8 1 2500 325 2500 1560 2000 15695 325 28010 27310 2 23102 45010 1890 41890 22010 1234 1890 52703

After the program is executed I want:

Patid PriDx SecDx1 SecDx2 SecDx3 SecDx4 SecDx5 SecDx6 SecDx7 SecDx8 1 2500 325 1560 2000 15695 28010 27310 2 23102 45010 1890 41890 22010 1234 52703

Observant SAS-Lers will note that I have not sorted the diagnosis codes. That is because the sorting was actually optional. The only reason I was bothering to sort the codes is that sorting was the main purpose of the original code in the SGF paper and it did no harm to sort the diagnosis codes for my purposes.

-----Original Message----- From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of Muthia Kachirayan Sent: Tuesday, March 16, 2010 6:26 PM To: SAS-L@LISTSERV.UGA.EDU Subject: Re: Problems with sorting an array with hash objects

It is difficult to understand the ERROR.

If you are learning hash objects and doing the sorting as an exercise, then it is ok. For sorting purpose, it is better to depend on Proc SORT rather than on Hash objects.

Neverthless, if provide a sample data as well as the desired output, then some of SAS-Lers will help you with.

On Tue, Mar 16, 2010 at 5: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. > > ************* 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.


Back to: Top of message | Previous page | Main SAS-L page