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

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

1 ACCEPTED SOLUTION

Accepted Solutions
DMoovendhan
Quartz | Level 8

%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.

View solution in original post

3 REPLIES 3
ballardw
Super User

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.

DMoovendhan
Quartz | Level 8

%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.

FlorianG
Calcite | Level 5

Thank you very much. 

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

Creating Custom Steps in SAS Studio

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.

SAS Training: Just a Click Away

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

Browse our catalog!

Discussion stats
  • 3 replies
  • 3747 views
  • 2 likes
  • 3 in conversation