BookmarkSubscribeRSS Feed
shkim
Fluorite | Level 6


%let k=6;
%let l=5;
%let m=1;

%test(nb=5);

%macro cccc;

 

%do %until(min>=0.7);

if pe<0.7 & ps>=0.7 then

do; %let l=%eval(&l-1); %let m=&m; end;

 

if ps<0.7 & pe>=0.7 then

do; %let m=%eval(&m+1);%let l=&l; end;

 

if pe<0.7 & pe<0.7 then do; 
%let l=%eval(&l-1);
%let m=%eval(&m+1); end;

 

%test(nb=5);

%end;


med[1,1]=%eval(&l+1);
msd[1,1]=%eval(&m-1);
print med msd; print &l &m;

%mend;
%cccc;

 

Hello,

I have the problem of ignoring conditional execution and executing all three cases.
what should i do?

3 REPLIES 3
FloT
Fluorite | Level 6

Hello,

 

Should you use macro statements i.e. with % sign:

%if %then %do %end

...?

Kurt_Bremser
Super User

You obviously have no clue what the macro facility is meant for.

See this:

%do %until(min>=0.7);
if pe<0.7 & ps>=0.7 then
do; %let l=%eval(&l-1); %let m=&m; end;

Using macro statements this way can NEVER work. The %let statements are dealt with when the code for the data or proc step is fetched and compiled, so trying to execute them conditionally is nonsense.

 

And a condition like that:

%do %until(min>=0.7);

can also never work, as the macro facility will compare the text "min" with the text "0.7", so min>=0.7 is always true.

 

What are you trying to do?

 

Post your whole code, as what you have posted is missing lots of important items (like the procedure around the macro):


@shkim wrote:


%let k=6;
%let l=5;
%let m=1;

%test(nb=5);

%macro cccc;

 

%do %until(min>=0.7);

if pe<0.7 & ps>=0.7 then

do; %let l=%eval(&l-1); %let m=&m; end;

 

if ps<0.7 & pe>=0.7 then

do; %let m=%eval(&m+1);%let l=&l; end;

 

if pe<0.7 & pe<0.7 then do; 
%let l=%eval(&l-1);
%let m=%eval(&m+1); end;

 

%test(nb=5);

%end;


med[1,1]=%eval(&l+1);
msd[1,1]=%eval(&m-1);
print med msd; print &l &m;

%mend;
%cccc;

 

Hello,

I have the problem of ignoring conditional execution and executing all three cases.
what should i do?


 

shkim
Fluorite | Level 6

ex data)

proc iml;
ze_0={1,2,3};
zs_0{1,3,5};
ze_1={2,3,4};
zs_1={2,4,2};
ze_2={1,3,2};
zs_2={2,5,4};
quit;

 

pe=#{max(ze_i[&l,1],zs_i[&m,1])>=ze_0[&l,1]}/nb
ps=#{max(zs_i[&l,1],zs_i[&m,1])>=zs_0[&m,1]}/nb

i=1,2
nb=2


I have already complete macro program code that computes pe and ps. (%test)
but, i don't know how to code this part.

 

Initial value l=3 , m=1

if pe < 0.05 then I = l-1, If ps < 0.05 then m = m + 1,

and pe and ps must be repeated until both are greater than 0.05.

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
  • 3 replies
  • 981 views
  • 2 likes
  • 3 in conversation