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

Innovate_SAS_Blue.png

Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.

If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website. 

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
  • 323 views
  • 1 like
  • 2 in conversation