BookmarkSubscribeRSS Feed
Lawongd
Calcite | Level 5

 

after writing the below code, I am trying to write the code as a function in the next code but I receive errors what am I doing wronging?

proc iml;
mean_1 = 268.1; print mean_1; 
mean_2 = 384.4; print mean_2;
s_1=124.8; print s_1;
s_2=168; print s_2;
s_pooled = sqrt((s_1**2 + s_2**2)/2);
print(s_pooled);
md =mean_1 - mean_2;print md;

d=abs(md)/s_pooled;

print(d);
quit;

 

 

 

proc iml;
start cohen.d (s_1, s_2, mean_1, mean_2); s_pooled = sqrt((s_1**2 + s_2**2)/2); md = mean_1 - mean_2; return (abs(md)/s_pooled); finish cohen.d; print (cohen.d (124.8, 168.3, 268.1, 384.4))


quit;

3 REPLIES 3
PaigeMiller
Diamond | Level 26

Show us the SAS log so we can see the errors (and the code too). Please copy the log and paste it into the window that appears when you click on the {i} icon.

--
Paige Miller
Lawongd
Calcite | Level 5
here is the log
 
1 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
72
73 start cohen.d (s_1, s_2, mean_1, mean_2);
_____
180

ERROR 180-322: Statement is not valid or it is used out of proper order.

74 s_pooled = sqrt((s_1**2 + s_2**2)/2);
________
180

ERROR 180-322: Statement is not valid or it is used out of proper order.

75 md = mean_1 - mean_2;
__
180

ERROR 180-322: Statement is not valid or it is used out of proper order.

76 return (abs(md)/s_pooled);
______
180

ERROR 180-322: Statement is not valid or it is used out of proper order.

77 finish cohen.d;
______
180

ERROR 180-322: Statement is not valid or it is used out of proper order.

78
79 print (cohen.d (124.8, 168.3, 268.1, 384.4))
_____
180
ERROR 180-322: Statement is not valid or it is used out of proper order.

80 quit;

81
82 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
Rick_SAS
SAS Super FREQ

Module names cannot include a dot (.)

They have the same rules as SAS variable names.

Change the module name to cohen_d and all will be well.

 

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!

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
  • 3 replies
  • 736 views
  • 0 likes
  • 3 in conversation