Good evening,
does anyone know how to use the %input statement in a macro in order to read in a value for a macro variable?
I use SAS Enterprise Guide, so the macro is written in the code window.
My first attempts unfortunately didn't work.
I tried something like this:
%macro identi; %put Type in your name; %input name; %put Type in your age; %input age; %put &name is &age years old; %mend identi; %identi;
When you start the program, there is no possibility for the user to type in the values for the variables. Only the log window opens.
Do I have to program an extra window where the user can type in the variable values or is there something else wrong?
Any help would be greatly appreciated.
Regards,
FlorianG
%input works well in sas PC and in command prompt, but for command prompt sas you can use x command and echo instead of %put to pass on the message to the interface.
_prompt_ works well in noth sas pc and in sas EG.
For EG you may want to look at PROMPT.
The %input and %window statements were created before much in the GUI. Also, the variables you create this way would exist for the duration of the macro (brief). You would want to add %Global statements to make the varaibles persist after the macro runs. See the documentation on scope of macro variables.
%input works well in sas PC and in command prompt, but for command prompt sas you can use x command and echo instead of %put to pass on the message to the interface.
_prompt_ works well in noth sas pc and in sas EG.
Thank you very much.
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Check out this tutorial series to learn how to build your own steps in SAS Studio.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.