BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
BroniusBaniulis
Calcite | Level 5

I am writing a genetic algorithm implementation from python and I need to call some sas procedures inside the ObjectFunction that i am defining. For example when i try to use

proc compare base=selected_row compare=evolving_individual outstats=compare_result noprint;
run;

inside my objective function i get an error saying 

 

ERROR: Subroutine 'fitness_sso' was not terminated with ENDSUB.
ERROR: Execution terminating because of previous errors.
 
If i remove the call in my objective function to the 'proc compare' then the genetic algorithm runs to completion.
 
Any suggestions how i can call procedures inside the objective function? What about my own defined macros? If i reference my own macro like so %macro_call(var1, var2); then i also get the same error of the objective function not termintated with ENDSUB...
 
Thanks for any help on this, but there is just not enough documentation and examples on genetic algorithm implementation.
1 ACCEPTED SOLUTION

Accepted Solutions
StevenGardner
SAS Employee

It's true that you can't execute SAS procedures directly from within your PROC GA objective function. The key is to create a macro that calls the procedures you wish to execute. Then, in your objective function definition you can call the macro with the 'run_macro' function. 

 

The following SGF paper from 2013 demonstrates how to use run_macro from within a function definition:https://support.sas.com/resources/papers/proceedings13/033-2013.pdf

View solution in original post

1 REPLY 1
StevenGardner
SAS Employee

It's true that you can't execute SAS procedures directly from within your PROC GA objective function. The key is to create a macro that calls the procedures you wish to execute. Then, in your objective function definition you can call the macro with the 'run_macro' function. 

 

The following SGF paper from 2013 demonstrates how to use run_macro from within a function definition:https://support.sas.com/resources/papers/proceedings13/033-2013.pdf

sas-innovate-white.png

Missed SAS Innovate in Orlando?

Catch the best of SAS Innovate 2025 — anytime, anywhere. Stream powerful keynotes, real-world demos, and game-changing insights from the world’s leading data and AI minds.

 

Register now

Discussion stats
  • 1 reply
  • 1000 views
  • 1 like
  • 2 in conversation