Hi Everyone, The discussion here really helps me a lot. I am new to Hash process so I will not have any question here. Based on the simulated data, I find the array approach is so efficient. I would like to make myself clear about it and below, I try to teach myself with explanation of each step. I have 3 questions and it would be very much helpful if you could help me to clarify them. Thank you so much and have a nice Holiday. HHC ********************************************************************************** *My 1st question is the how SAS process the code: 1. at the benning, SAS goes to section 2 and collect prc and time record from 1 to min(10,000 , last.object) 2. then SAS goes to Section 3, take the first record of have and run the checking with the array price(); *Once is done, SAS redo the 2 section with 2nd record of have I wonder why SAS doesn't run the section 1 from the beginning to the end before moving onto section 3. What line of code prevent SAS from doing so? *My 2nd question is after finishing 1 record of have, why don’t we reset nn=0; end; output; nn=0; end; *My erd question is: what is the role of :; call missing (of prc(*)); call missing (of tim(*)); ***************************************************************************************************; data want(keep=object time price level greater exit_prc); *Section 1: declare array specification; array prc(10000) _temporary_; array tim(10000) _temporary_; kk=0; call missing (of prc(*)); call missing (of tim(*)); *Section 2: gathering records in the array prc() and tim(). These array is Max 10,000 records; do until (last.object); set have; by object; kk+1; prc(kk)=price; *start from price(0+1)?; tim(kk)=time; end; *Section 3: the main code of checking first record with price above level; ntot=kk; *the ntot is the value of record in the prc()/tim() array, Max 10,000; nn=0; *Reset nn=0 for below do loop; do until (last.object); set have; *open file have, start with the first record; by object; nn+1; *start with nn=0; greater=0; do i=nn+1 to ntot; *first I value =1 to the max ntot record above, max 10,000; if (prc(i)>level) then do; greater=tim(i); exit_prc=prc(i); leave; *exit the checking loop to OUTPUT; end; end; output; end; run;
... View more