Basically I have a variety of PROCs and DATA steps that are organized in various programs in my SAS EG project. What I want to do is build a make-shift user interface using %macro where users can modify the variables (I will add comments to display the choices of variables they can choose) and then run the code based on those variables. An example would be date, where the user can run the relevant PROCs for certain dates of their choice but changing the macro variable inputs accordingly.
My question is when I attempt this, the macros variables don't run unless the underlying macro code itself runs first, but what I am looking to accomplish is similar to how functions work in VBA or other object oriented programming languages.
I have done similar things. I don't think you really want people looking at and then modifying your SAS code, even if you give them instructions just to change these few lines and don't touch the rest.
What I did was create a simple text file that looks like this:
Start Date 01JAN19
End Date 31AUG19
and that's it. Then the user modifies that text file, stores the file in some pre-specified server location, and then the SAS program reads this, creates the desired macro variables, and then it goes ahead and runs.
Can you say more about how you are trying to do this currently?
I don't know much about building UI's in EG. But the concept of a macro is that it is a parameterized unit of code.
If you write a macro which takes a date as a parameter, you can put the .sas file with that macro definition in an autocall library. Users would not need to see the macro definition, or run it them selves.
They would just call the macro: %Try(date='24Feb2020'd)
Is your question, "How do I build a UI in EG that will allow a user to enter a value, and then execute a macro, passing the user's value as a parameter in the macro call?"
If so, I would look int stored processes and custom tasks.
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.