Desktop productivity for business analysts and programmers

How do you use the %input statement?

Accepted Solution Solved
Reply
New Contributor
Posts: 2
Accepted Solution

How do you use the %input statement?

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


Accepted Solutions
Solution
‎09-19-2016 05:30 AM
Contributor
Posts: 61

Re: How do you use the %input statement?

%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


All Replies
Super User
Posts: 11,134

Re: How do you use the %input statement?

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.

Solution
‎09-19-2016 05:30 AM
Contributor
Posts: 61

Re: How do you use the %input statement?

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

New Contributor
Posts: 2

Re: How do you use the %input statement?

Thank you very much. 

☑ This topic is solved.

Need further help from the community? Please ask a new question.

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