BookmarkSubscribeRSS Feed
art297
Opal | Level 21

: FWIW, I wouldn't recommend using the monotonic() function as it could easily introduce a wrong answer.  There MUST be a reason why it has remained undocumented all of these years.  Personally, I wouldn't take the risk.

Haikuo
Onyx | Level 15

To Astounding: I hate this mouthful of hash() approach as well, the mere intention of it is to construct a one-pass solution, which in the end is proven to be lower efficient by Art. So that doesn't work out.

To Art and Fareeza: Agreed with your comments on last record. It only takes minor tweak to the current Hash() code to fix that:

data have;

input (fn ln) (:$20.) grade;

cards;

Ross Smith 11

Jayden Woo 10

Ross Smith 7

Jayden Woo 8

Ross Smith 6

;

/*theorically one-pass(I/O) approach*/

data want;

  declare hash full(ordered:'y');

  full.definekey('_n_');

full.definedata('fn','ln','grade');

full.definedone();

declare hiter hif('full');

declare hash hoh();

hoh.definekey('fn','ln');

hoh.definedata('fn','ln','lst','hil');

hoh.definedone();

  declare hash lst;

declare hiter hil;

do _n_=1 by 1 until (done);

  set have end=done;

l_grade=grade;

  if hoh.find() ne 0 then do;

lst=_new_ hash (ordered:'d'); 

lst.definekey('_n_');

lst.definedata('fn','ln','l_grade');

lst.definedone();

  hil=_new_ hiter ('lst');

hoh.replace();

end;

  lst.replace();

full.replace();

end;

do _rc=hif.next() by 0 while (_rc=0);

hoh.find();

hil.first();

output;

_rc=hif.next();

end;

stop;

drop _rc;

run;

Haikuo

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 16 replies
  • 1512 views
  • 0 likes
  • 5 in conversation