BookmarkSubscribeRSS Feed
AmirKing
Calcite | Level 5

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.

2 REPLIES 2
PaigeMiller
Diamond | Level 26

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.

--
Paige Miller
Quentin
Super User

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.

 

 

The Boston Area SAS Users Group is hosting free webinars!
Next up: Lisa Mendez & Richann Watson present Get Tipsy with Debugging Tips for SAS® Code: The After Party on Wednesday Jul 16.
Register now at https://www.basug.org/events.

hackathon24-white-horiz.png

The 2025 SAS Hackathon Kicks Off on June 11!

Watch the live Hackathon Kickoff to get all the essential information about the SAS Hackathon—including how to join, how to participate, and expert tips for success.

YouTube LinkedIn

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 643 views
  • 0 likes
  • 3 in conversation