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;
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.
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;
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 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.