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

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-2024.png

 

Time is running out to save with the early bird rate. Register by Friday, March 1 for just $695 - $100 off the standard rate.

 

Check out the agenda and get ready for a jam-packed event featuring workshops, super demos, breakout sessions, roundtables, inspiring keynotes and incredible networking events. 

 

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.

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