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.

 

hackathon24-white-horiz.png

The 2025 SAS Hackathon Kicks Off on June 11!

Watch the live Hackathon Kickoff to get all the essential information about the SAS Hackathon—including how to join, how to participate, and expert tips for success.

YouTube LinkedIn

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