BookmarkSubscribeRSS Feed
shkim
Fluorite | Level 6

Hi,


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

when  , 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.

 

 

**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

 

l=3 to 1;

m=1 to 3;

i=1,2
nb=2;


 

4 REPLIES 4
PaigeMiller
Diamond | Level 26

IF statements in IML work the same as IF statements anywhere else. So it's not clear to me exactly what your problem is. Can you be much more specific?

--
Paige Miller
shkim
Fluorite | Level 6

I posted the code in the attachment,
I'm not sure of the last part of the macro code.

 

I don't know how to code for this part.


- if pe<0.05 then l = l-1 

  if ps <0.05 then m = m + 1  , and pe and ps must be calculated until both pe and ps are greater than 0.05..

 

PaigeMiller
Diamond | Level 26

And what happens when you execute this code? 

 

Show us the SASLOG of the relevant parts. Use the {i} button and paste the SASLOG of the relevant parts into the {i} window.

--
Paige Miller
shkim
Fluorite | Level 6
data ze_0;
input COL1 @@;
cards;
  0.16013 
  0.32026 
  0.80064 
  0.64051 
  0.64051 

run;

data zs_0;
input COL1 @@;
cards;
-0.16013
-0.48038
0.32026
0.48038
0.80064
run;

data ze_1;
input COL1 @@;
cards;
-0.16013
-0.16013
-0.16013
0.00000
0.32026
run;

data zs_1;
input COL1 @@;
cards;
-0.64051
-1.28103
-0.80064
-0.80064
-0.32026
run;

data ze_2;
input COL1 @@;
cards;
1.92154
2.40192
2.40192
0.96077
1.92154
run;

data zs_2;
input COL1 @@;
cards;
1.60128
1.44115
0.48038
1.12090
2.08167
run;

data ze_3;
input COL1 @@;
cards;
0.32026
1.44115
1.76141
1.76141
2.08167
run;

data zs_3;
input COL1 @@;
cards;
0.16013
-1.44115
-0.16013
-0.48038
0.32026
run;

data ze_4;
input COL1 @@;
cards;
0.00000
0.00000
0.96077
0.64051
0.64051
run;

data zs_4;
input COL1 @@;
cards;
-0.80064
-1.60128
-1.12090
-1.60128
-0.64051
run;

data ze_5;
input COL1 @@;
cards;
-1.28103
-0.80064
-0.48038
-0.64051
-0.96077
run;

data zs_5;
input COL1 @@;
cards;
-1.60128
-0.48038
0.48038
0.48038
0.16013
run;

When you run this data set and attachment macros (new attachments)
There is no error, but the desired result is different.

 

% let l = 5;
% let m = 1;
% test (nb = 5, l = & l, m = & m);

 

This is result in pe = 0.6 ps = 0.8.

 

Since pe < 0.7,

 

Next is   

% let l = 4; % let m = 1; % test (nb = 5, l = & l, m = & m);
This should be done.

 

With such a routine, when l = 3 and m = 1, pe and ps are both greater than 0.7 for the first time.

However, if the macro aaa is executed, the value of l = 4 and m = 2 appears, so i don't know why the value is wrong.

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!

Multiple Linear Regression in SAS

Learn how to run multiple linear regression models with and without interactions, presented by SAS user Alex Chaplin.

Find more tutorials on the SAS Users YouTube channel.

From The DO Loop
Want more? Visit our blog for more articles like these.
Discussion stats
  • 4 replies
  • 1541 views
  • 0 likes
  • 2 in conversation