BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Red_Squirrel
Calcite | Level 5

Certainly:

Data want;

Set have;

If ((value1 < value2 < value3) or (value1 < required_result and value2 < required_result and value3 < required_result)) and (_n_ > 2) and (_n_ > max_recordnum) then do;

max_recordnum = _n_ + 3;

Saved_average = average1;

End;

Retain max_recordnum saved_average;

If saved_average = . Then required_result = average1;

Else required_result = saved_average;

Run;

IS the problem here because required_result is used in the first if condition before even it has been creared?

Astounding
PROC Star

OK, it's looking a little clearer.  The OR condition should look at SAVED_AVERAGE, rather than REQUIRED_RESULT.  SAVED_AVERAGE is retained, but REQUIRED_RESULT begins each observation as missing:

If ((value1 < value2 < value3) or (value1 < saved_average and value2 < saved_average and value3 < saved_average)) and (_n_ > 2) and (_n_ > max_recordnum) then do;

Red_Squirrel
Calcite | Level 5

Smiley Happy Thank you very much, Astounding!

all works now as it is supposed to!

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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
  • 17 replies
  • 1657 views
  • 7 likes
  • 3 in conversation