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 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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
  • 2163 views
  • 0 likes
  • 5 in conversation